Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8352497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:58:41+00:00 2026-06-09T08:58:41+00:00

I am attempting to use CURL to send a simple POST parameter (an int)

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T08:58:42+00:00Added an answer on June 9, 2026 at 8:58 am

    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"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been attempting to use ASP.NET MVC remote validation for username login access
I am attempting to use PHP and cURL to: Access a web-form & maintain
Attempting to use asp.net mvc's Action Result of File. So it would seem that
I am attempting to use libcurl to post XML data to a sort-of web
I'm attempting to use the new partial page caching available in ASP.NET MVC 3.
In attempting to use the Performance Tools on an ASP.NET website I'm getting various
Attempting to use the amazon API to obtain product data and currently failing miserably.
Im attempting to use Silverlight and MVC together. After creating a simple Silverlight application
I am attempting to use Castle Windsor in my automated tests like so: On
I'm attempting to use the Github v3 API and posting JSON to update a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.