0

I need to call a json script using curl terminal. following is the path I call from browser:

http://www.mydomain.com/?arg1=abc&arg2={"x":"y"}

But when I try this using curl it gives me error. Before posting this question I tried googling it couldn't find any specific answere. May be I am noob that couldn'd figured anything from this thread:

curl json post request via terminal to a rails app

Community
  • 1
  • 1
user739711
  • 1,842
  • 1
  • 25
  • 30

1 Answers1

0

The curl command Bob posted is a POST request.

You are trying to provide the data using a GET request.

curl -v -H "Accept: application/json" -H "Content-type: application/json" "http://mydomain.com/?arg1=abc&arg2={'x':'y'}"

In case this doesn't work, could you post the error you're getting here?

martinjlowm
  • 871
  • 5
  • 8
  • This command doesn't run properly on windows cmd-prompt. I think the url should be double-quoted. But then again, how do we double-quate the Json-key-value pair?... btw I tried url double quoted and json single quoted without any success... – user739711 Mar 22 '12 at 11:51
  • I just added the double quotes, try it now. – martinjlowm Mar 22 '12 at 12:04
  • tried that already.. as mentioned in my above comment.. no success!! – user739711 Mar 22 '12 at 14:58
  • Mind sharing your error then? or atleast the curl output. It's set to verbose, so it should give us plenty of information. – martinjlowm Mar 22 '12 at 15:07
  • I got the problem. Actually I was trying this: curl http://www.mydomain.com/?arg1=abc&arg2={%22x%22:%22y%22} And the currect command is: curl http://www.mydomain.com/?arg1=abc&arg2=%7B%22x%22:%22y%22%7D Yeah I know I am getting silly lately..URL-encoding has been mentioned on the first page of curl docs. Silly chrome was giving me first URL, without encoding "{" and "}". – user739711 Mar 22 '12 at 19:22