I am trying to test a REST api.

Using any other web browser, I can paste the URL into the address field and gt the desired result:


Trying the same using curl:

curl 'https://some.company.com/SomeAppAPI?cmd=setSomeData&token=d713cebde464&data={"firstName":"TEST"}'

(I have to quote the URL, otherwise bash will take it apart.)

the API comes back with an error message saying:

data must be json encoded array

How would I properly encode this on the command line or would there be any option to have curl read the JSON from a file, while doing a GET request. I know how to make curl read from a file using a POST request, but the API doesn't seem to support HTTP POST here.

  • 2
    An array in JSON is written [...]. – Kusalananda Apr 23 at 7:48
  • So you mean it should read: curl 'some.company.com/…{"firstName":"TEST"}]' ? Unfortunately this doesn't work as well. – TorstenS Apr 23 at 10:02
  • And the fun thing: It works as expected using wget. – TorstenS Apr 23 at 10:03
  • Does it work with curl -g? {...} may trigger the special "brace expansion" that curl supports in URLs. – Kusalananda Apr 23 at 10:28

Your Answer

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

Browse other questions tagged or ask your own question.