Reputation: 1494
I have a web service that contains a method DoWork(). This method will be used to retrieve data from a database and pass the data back to the caller in JSON format.
[OperationContract]
[WebInvoke(Method = "GET", UriTemplate = "doWork")]
public Stream DoWork()
{
return new MemoryStream(Encoding.UTF8.GetBytes("<html><body>WORK DONE</body></html>"));
}
I have composed a fiddler request just to verify my method is available.
if I execute this from fiddler, the method in my web service gets called. But I can't seem to figure out how to construct a cURL command that will do the same thing.
Upvotes: 3
Views: 13116
Reputation: 10953
Perhaps the easiest approach to this is having Chrome create that curl command line for you, especially when the request involves many headers and complicated POST data.
Open the developer tools by pressing F12 and going to Network
. Then run whatever call you want to monitor.
(In my example you can see what happens when you open questions here on stack overflow)
Then right click on the relevant line and select copy as cURL (cmd)
if you are on Windows (for Linux use the other)
This will give you a command line similar to this:
curl "http://stackoverflow.com/questions" -H "Accept-Encoding: gzip, deflate, sdch" -H "Accept-Language: de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4" -H "Upgrade-Insecure-Requests: 1" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36" -H "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8" -H "Referer: ..." -H "Cookie: ..." -H "Connection: keep-alive" --compressed
If you experience problems you should add -v
to see more details, for a detailled explanation of the commands you can see the manual.
Perhaps all you need to add to your already existing curl command line are those browser specific headers (User-Agent, Accept, ...)
Upvotes: 4