Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3852032
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T17:15:17+00:00 2026-05-19T17:15:17+00:00

I have not been working with Monotouch (or the iphone for that matter) for

  • 0

I have not been working with Monotouch (or the iphone for that matter) for too long, so I guess my problem is experience related.

I created an application that needs to communicate with a web service via json. I used the ported Json.NET library found here : https://github.com/chrisntr/Newtonsoft.Json

First I created a windows application using the Json.NET library, just to quickly try it out. It worked perfectly. Then I wrote the same exact code in MonoDevelop, and the server returns an error message that it cannot recognize the query at all.
Note that I have checked if the serializer does its job properly – the json string is formatted correctly. Moreover, both applications behave in the same manner until getting the response from the server.

JsonSerializer serializer = new JsonSerializer();
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(the uri of the service);
request.Method = "post";
request.ContentType = "application/x-www-form-urlencoded";
Query login = new Query(); // the object that will be serialized
login.module = "auth";
login.data.Add("username", username goes here);
login.data.Add("password", password goes here);
using (Stream s = request.GetRequestStream())
 {
                using (StreamWriter w = new StreamWriter(s))
                {
                   StringWriter sWriter = new StringWriter(new StringBuilder());
                   serializer.Serialize(sWriter, login);
                  w.Write("&query="+sWriter.ToString());
                }
 }
using (HttpWebResponse resp = request.GetResponse() as HttpWebResponse)
        {
            var reader = new StreamReader(resp.GetResponseStream());
            JsonReader  r = new JsonTextReader(reader);
  Response login_response = (Response)serializer.Deserialize(reader, typeof(Response));
        }

When I first wrote the windows application, the server could not recognize my queries because the Content header was set to “application/json” and because it requires the query to be delivered as a key-value pair (with “query” as the key). That is the reason for the w.Write(“query = “+sWriter.ToString()); . In the php script that was provided as an example of calling the service, this line was setup like this:
curl_setopt($ch, CURLOPT_POSTFIELDS, array(‘query’=>jsonEncode($data)));

However since I fixed the content type headers and added the “query=” in front of the string, the code works perfectly in Visual Studio and Mono Develop. It even ran on my android phone after I wrote it in Java. However, in MonoTouch, the server always fails to recognize the request stream as a query. What could be the cause of this? is there anything special that happens to the request stream in MonoTouch as opposed to everywhere else? Again, I have checked the string that gets into the stream, it is correct and the same for all the test applications.

Thank you in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T17:15:18+00:00Added an answer on May 19, 2026 at 5:15 pm

    Reinstalled MonoDevelop and issue disappeared.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have not been working in SQL too long, but I thought I understood
I'm not a Notes programmer, however, for my sins, have been working on some
I have not used Windows Vista. I knew that many APIs have been changed/deprecated
I only want a list of files that have been added (not ones that
I have been working through projects involving packages that do all the web design
I have not been able to find a way to cancel/terminate asynchronous read operation
I am trying to use the following code, which I have not been able
There have been some questions about whether or not JavaScript is an object-oriented language.
I have been told and I'm not sure I believe this: Removing white space
I have been getting an error in VB .Net object reference not set to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.