I am trying to do a multipart call in C# from windows phone. I am sending the exact same json of a working android call but from wp I am getting this response body:
"errorNumber":90 - A JSONObject text must begin with '{' at character 0 of "}
The first char I am sending is {.
Why does it happen?
Here is my code:
public async Task postHttpClient(string serviceUrl, string requestObj)
{
Debug.WriteLine("postHttpClient");
try
{
var client = new HttpClient();
client.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "multipart/form-data");
Debug.WriteLine("requestObj: " + requestObj);
Debug.WriteLine("curly brace should be expected: " + (int)requestObj.Trim().ElementAt(0));
MultipartFormDataContent content = new MultipartFormDataContent();
var contentData = new StringContent(requestObj.Trim());
content.Add(contentData);
var responseVar = await client.PostAsync(serviceUrl, content);
responseVar.EnsureSuccessStatusCode();
Debug.WriteLine("responseVar: " + responseVar.ToString());
var body = await responseVar.Content.ReadAsStringAsync();
Debug.WriteLine("body: " + body);
}
catch (Exception e)
{
Debug.WriteLine("e: " + e.ToString());
}
}
and my fiddler:
Raw Headers
POST /MyServer/SendActivity/ HTTP/1.1 Accept: / Content-Length: 703 Accept-Encoding: identity Content-Type: multipart/form-data; boundary="e8763d7d-a53d-4baa-a6c7-c3bc37bd52a6" User-Agent: NativeHost Host: merp.techmobile.eu:8080 Connection: Keep-Alive Pragma: no-cache
Textview tab
--e8763d7d-a53d-4baa-a6c7-c3bc37bd52a6 Content-Type: text/plain; charset=utf-8 Content-Disposition: form-data
{"SendActivityRequest":{"activity":{...