Note that there are some explanatory texts on larger screens.

plurals
  1. POWCF Rest JSON service 400 bad request
    primarykey
    data
    text
    <p>So i wrote my first WCF project, seems like its working using my browser and jquery, but then i wrote a client and things messed up a bit... actually seems like everything i do with that client result in a 400 bad request response... so i've read some posts and found out a good way to sort things up is using fiddler, and started picking around...</p> <p>since fiddler can't identify my client, i've used my client to send the data directly to it... <a href="https://docs.google.com/file/d/0ByOtHJSZT_GtNHZqTVZMdVVqZEU/edit?usp=sharing" rel="nofollow">https://docs.google.com/file/d/0ByOtHJSZT_GtNHZqTVZMdVVqZEU/edit?usp=sharing</a> you can see a screenshot here.</p> <p>as i can see oly things that differs are the leack of some headers (that don't seems like really usefull to me) and one use content-type as application/jsonp the other text/html (wich i think is the main problem). The bad thing is i've setted the content-type header before sending the request, but with no result, please notice that in the right panel you can still see application/json. I'm getting confused.</p> <pre><code> private void SendSelectedFile() { string url = "http://" + WindowsFormsApplication1.Properties.Settings.Default.HostAddress + "/Service1.svc/rest/PostFileToServer"; string jsonMsg = "{\"fileContentAsBase64String\":\"" + this.textBox1.Text + "\",\"where\":\"D:\\Temp.dwg\"}"; byte[] buffer = System.Text.Encoding.UTF8.GetBytes(jsonMsg); HttpWebRequest wr = WebRequest.Create(new Uri(url)) as HttpWebRequest; wr.Method = "POST"; wr.ContentType = "application/json; charset=utf-8"; wr.ContentLength = buffer.Length; //wr.TransferEncoding = "UTF-8"; System.IO.Stream rs = wr.GetRequestStream(); rs.Write(buffer , 0, buffer.Length); rs.Close(); WebResponse response = wr.GetResponse(); } </code></pre> <p>and this is the interface of the service</p> <pre><code> [WebInvoke( Method = "POST", ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "/PostFileToServer" )] Boolean PostFileToServer(string fileContentAsBase64String, string where); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload