2

I try to post to localhost with some parameters in the URL. Everything just works fine in Fiddler. But cURL doesn't allow me to do it, with the error message below.

curl --data "Task=bake" http://localhost:49301/api/donut/run

{"Message":"No HTTP resource was found that matches the request URI 'http://localhost:49301/api/donut/run'.","MessageDetail":"No action was found on the controller 'Donut' that matches the request."}

In Fiddler I compose the request as follows: POST http://localhost:49301/api/donut/run?Task=bake

1

The following works:

curl --data '' http://localhost:49301/api/donut/run?Task=bake

The parameter "--data ''" seems to be important so curl does a POST and not a GET.

0

While you might technically be doing a "POST" request in fiddler (Which I've not used, but I do know a thing or two about HTTP), it looks to me very much like you are not actually posting your query, rather you are using a "PUT" (presumably combined with an empty post).

I believe that if you were to use curl http://localhost:49301/api/donut/run?Task=bake it would work fine.

[ A PUT request puts the parameters as part of the URL, a POST request instead puts them in the request header.

Its probable that your application is programmed to accept PUTS but not POSTS.

  • When I try your suggestion the web server comes back saying: "The requested resource does not support http method 'GET'." – chhenning Nov 23 '15 at 1:01
  • Ok, what about trying -data "ignore=me" localhost:49301/api/donut/run?Task=bake – davidgo Nov 23 '15 at 1:33
  • Sorry, that doesn't work either – chhenning Nov 23 '15 at 2:07
0

Using curl with the --data argument causes curl to POST, but also to send the arguments as part of the body of the request rather than as arguments passed via the URL.

Given the error you're receiving is an MVC routing error stating that the route can't be resolved to an action, I'm guessing the action that you're targeting isn't set up to receive it's parameters from the body of the request.

Try:

curl -d '' http://localhost:49301/api/donut/run?Task=bake

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.