none
How to pass web service post method request body in fiddler RRS feed

  • Question

  • I have a very simple web service in .net

    [WebInvoke(Method = "POST",
    ResponseFormat = WebMessageFormat.Json,
    BodyStyle = WebMessageBodyStyle.Wrapped,
    UriTemplate = "xml?id={id}")]

    string XMLData(string id);

    When I am checking it in Fiddler by passing following URL,its working fine

    http://localhost:60104/IO_100_Service.svc/xml?id=123}

    but when I am passing the parameter in request body of fiddler its not working

    URL
    http
    ://localhost:60104/IO_100_Service.svc/xml

    Request Header
    Content-Type: application/x-www-form-urlencoded

    Request Body
    id
    =123

    If anybody has any Idea about it, please help me with this.

    Sunday, April 22, 2012 5:20 PM

Answers

  • It seems that you cannot do that, but you can change your code:

                    [WebInvoke(UriTemplate = "/xml/", Method = "POST",
                BodyStyle = WebMessageBodyStyle.Wrapped,
                ResponseFormat = WebMessageFormat.Json)]
            string XMLData(string id);
            public string XMLData(string id)
            {
                return id;
            }

    The request header in fiddler:

    Host: localhost:15587
    Content-Length: 22
    Content-Type: application/json;charset=UTF-8

    and the request body in fiddler:

    {
      "id":"100"
    }

    and set the method as "POST" and request URL as follows:

    http://localhost:15587/Service1.svc/xml/ 

    and then you can test it in Fiddler, you will see the following test result:

    {"XMLDataResult":"100"}


    Please mark the replies as answers if they help or unmark if not. If you have any feedback about my replies, please contact msdnmg@microsoft.com Microsoft One Code Framework

    Monday, April 23, 2012 10:26 AM
    Moderator