I am trying to multipart a comfort web service using C # from my Windows Phone.
This is the httpclient I'm using for
Even if the string I'm sending is this:. {"AuthenticationRequest": {"Company": "3000", "identificationCode": "111", "Username": "Jack", "Password": "Paz"}}
I am receiving a description of this message in my reaction body:
will start with a JSONObject text 'on' character 0 "on}
Here is my code:
Task postHttpClient async public (string serviceUrl, string requestObj) {var customer = New HttpClient () try {; client DefaultRequestHeaders.TryAddWithoutValidation ("Content Type", "Multipurpose / Form-Data"); MultipartFormDataContent Content Re = new MultipartFormDataContent (); Debug.WriteLine ("RequestObject:" + requestObject); content.Add (new string content (request obz, encoding. UTF8), "authentication record"); Var response = wait client.PostAsync ( ServiceUrl, content); responseVar.EnsureSuccessStatusCode (); debug.lightline ("ResponseWeek:" + Reaction.Towstring ()); Var Body = Wait for response. Continent Redeststring Async (); Debug Farewell line ("body:" + body); } Hold (exception e) {Debug.WriteLine ("E:" + E. ToString ()); What is wrong with me? Note: The first letter of my variable has been received as {
debug Virline ("first letter:" + request obz [0]);
I also trimmed that variable with any changes
After the
It may be that the service with the expectation of your service / JSN content and you can use multipart / form - sending the data.
Try it:
var message = new HTTP and message (HTTP Meth. Post, new URI (service URL)); Message.Content = new StringContent (json, encoding. Utf8, "app / jason"); Var results = eliminate the client. SendAsync (Message, Cancellation Token);
No comments:
Post a Comment