Q: POST parameters in CURL I am attempting to use CURL to send a simple POST parameter (an int) to an ASP.NET web api controller POST method like so:
curl -d "id=1" --ntlm --user <user>:<pass> http://dev.test.local/api/test

Is this the correct way to attach data to the POST for Curl? I can contact the URL fine but it seems the parameter 'id' doesn't get passed because i get the following error returned from the server:
"The parameters dictionary contains a null entry for parameter 'id' of non-nulla
ble type 'System.Int32' for method 'System.String Post(Int32)' in 'Test.Si
te.Controllers.TestController'. An optional parameter must be a reference type,
a nullable type, or be declared as an optional parameter."

My POST method in the OrderController is as follows:
    // POST api/test
    public string Post(int id)
    {
        return "Post successful";
    }

Any help is much appreciated.

A: The problem is that simple types such as int, string, etc. cannot be model-bound with the data from the message body unless you tell it explicitly as below:
public string Post([FromBody]int id)
{
    return "Post successful";
}

The other solution is that you can ask these types of values from RouteData or query string.

A: Personally I would use a simple DTO and call via JSON.
route:
        routes.MapHttpRoute(
            name: "DefaultApi",
            routeTemplate: "api/{controller}",
            defaults: new {   }
        );

controller & DTO:
[DataContract]
public class valueDto
{
    [DataMember]
    public int id { get; set; }
}

public class TestController : ApiController
{
    // POST api/values
    public string Post(valueDto value)
    {
        return string.Format("Post successful {0}", value.id);
    }
}

Call with curl:
curl -d "{ "id": 1 }" --ntlm --user <user>:<pass> http://dev.test.local/api/test -H "Content-Type:application/json"

But
Just to follow on a little from tugberk's answer and referencing another answer and here . 
When you use the FromBody attribute you will also need to send the "Content-Type" as Content-Type: application/x-www-form-urlencoded. You will also need to change the call not have the "id=1" and instead use "=1" e.g.
curl -d "=1" --ntlm --user <user>:<pass> http://dev.test.local/api/test -H "Content-Type:application/x-www-form-urlencoded"

