Home > Net >  CURL command with --data-raw JSON, Unexpected character error
CURL command with --data-raw JSON, Unexpected character error

Time:10-16

Hi I need to send JSON format through the CURL command but I am getting an error.

curl --request POST "https://app.io/api/graphql?accountId=Xzg" --header "x-api-key: WHpnV=" --header "Content-Type: application/json" --data-raw "{applications(limit: 2) {nodes {name}}}"

So the problematic part is data-raw, although I have checked it online it's Valid JSON.

--data-raw "{applications(limit: 2) {nodes {name}}}"

Response:

{"metaData":null,"resource":null,"responseMessages":[{"code":"DEFAULT_ERROR_CODE","level":"ERROR",
"message":"Unable to process JSON Unexpected character ('a' (code 97)): 
    was expecting double-quote to start field name","exception":null,"failureTypes":[]}]}

I tried different ways how I could change this request data but without success. Can someone please assist me how I should change this query which was definitely generated as the proper one from some app. Thanks!

CodePudding user response:

Solution:

 --data-raw '{"query": "{applications(limit: 2) {nodes {name}}}" }'
  • Related