简体   繁体   中英

POST method, error 400l bad request. asp.net

I'm trying to send data from my iPhone to a windows server 2008. I found a tutorial, but I'm unfamiliar with asp.net.

So this is my code (in asp.net)

   [OperationContract]
    [WebInvoke(Method = "POST",
        UriTemplate = "InsertEmployee?names={name}&lastnames={lastname}",
        BodyStyle = WebMessageBodyStyle.Wrapped,
        RequestFormat = WebMessageFormat.Json,
        ResponseFormat = WebMessageFormat.Json)]
        //ResponseFormat = WebMessageFormat.Xml)]
    //method
    bool InsertEmployeeMethod(string name, string lastname);
    //

and, I tried testing the installation with "postman", software that let me see the errors and checks in the Method. I sent a test of the code via postman.

And in Google, like this:

http://192.168.1.209/JsonWcfService/GetEmployees.svc/InsertEmployee?name=ildaguin&lastname=pregunton

That returns an Error 400 (Bad request).
How do I resolve this?

One way 400 Bad Request occurs is a syntax error. More details would be helpful including the message you are sending with Postman and the error returned if an error is returned.

If an error is not returned in Postman, then I would compare that to the message right before it is being sent in debug from your code. I can help you out with both if you can post additional details / code.

It is likely that you are missing some information or there is some spelling issue in the request, is a header variable required perhaps ( maybe Bearer token ). Are some words not case correct?

Good Luck

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM