user1867256
user1867256

Reputation: 55

Formulate POST request in curl

I'm using curl to send POST request to web service http ://localhost 2325//Service

How can I desirialize body of the POST request into a variable which I could then access within my POST method ?

Can someone give me an example?

This is my method

[WebInvoke(RequestFormat = WebMessageFormat.Json, UriTemplate = "/user", Method = "POST")] public void Create(User us)

Class User contains user_id and user_name.

Can anyone please help? All I need is an example how to formulate POST request in curl

I've tried this but it doesn't work

curl -v -H "Accept: application/json" -H "Content-type: application/json" -X POST -d ' {"user":{"user_name":"Name1","user:id":"11"}}' http:// localhost :3000/api/1/users

Upvotes: 4

Views: 1172

Answers (1)

cfeduke
cfeduke

Reputation: 23236

Because you named your parameter us in the method signature your JSON needs to be:

{"us":{"user_name":"Name1","user:id":"11"}}

Alternatively rename your parameter "user" in the method signature.

Upvotes: 1

Related Questions