web services - cURL command for HTTP GET -
i have web service contains method dowork(). method used retrieve data database , pass data 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 fiddler request verify method available.
if execute fiddler, method in web service gets called. can't seem figure out how construct curl command same thing.
perhaps easiest approach having chrome create curl command line you, when request involves many headers , complicated post data.
open developer tools pressing f12 , going network
. run whatever call want monitor. (in example can see happens when open questions here on stack overflow)
then right click on relevant line , select copy curl (cmd)
if on windows (for linux use other)
this give command line similar 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, 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 experience problems should add -v
see more details, detailled explanation of commands can see manual. perhaps need add existing curl command line browser specific headers (user-agent, accept, ...)
Comments
Post a Comment