sebastian.roibu
sebastian.roibu

Reputation: 2879

WCF Make a POST request with a parameters

I have a wcf service that exposes a rest endpoint. I want to test it using fiddler. I have a method like this :

 [WebInvoke(Method = "POST", UriTemplate = "EditContact", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
    string EditContact(string idContact, Contact Contact);

I input :

POST http://192.168.1.31/ContactLibrary2.0/Service.svc/rest/DeleteContact HTTP/1.1

User-Agent: Fiddler
Host: 192.168.1.31
Content-Type : application/json; Charset=UTF-8

{
"idContact":"67697",
"firstName":"6767",
"lastName":"afdgsg",
"email":"dfghdfdb",
"age":"120",
"street":"sdf",
"city":"dfghgfhjhdfgsdv",
"country":"sdfsd"
}

More code from my project you can see : HERE

I get http 400 error (bad request error). Ideas ?

Upvotes: 2

Views: 6470

Answers (1)

Rajesh
Rajesh

Reputation: 7886

Your request should look as shown below:

POST  http://192.168.1.31/ContactLibrary2.0/Service.svc/rest/DeleteContact HTTP/1.1
User-Agent: Fiddler
Content-Type: application/json

{
    "idContact":5,
    "Contact":{
        "idContact":"67697",
        "firstName":"6767",
        "lastName":"afdgsg",
        "email":"dfghdfdb",
        "age":"120",
        "street":"sdf",
        "city":"dfghgfhjhdfgsdv",
        "country":"sdfsd"
    }
}

Upvotes: 8

Related Questions