1

I am trying to invoke API from the data pipeline where i am getting below error . This is what i am trying .

aws apigateway test-invoke-method --rest-api-id  int836id123 --resource-id  1ukckkkwq1 --http-method POST --body "{\"QUEUEURL\": \"\",
\"BUCKETREGION\": \"us-east-1\",
\"FLAGFILE\": \"\",
\"FTPUSERID\": \"abcd-test-parameter\",
\"FTPPATH\": \"/abcd/Incr1\", 
\"FTPPASSWORD\": \"abcd-test-parameter\", 
\"PARAMETERSTOREREGION\":\"us-east-1\",
\"ISFTP2S3\": \"false\", 
\"FTPSERVER\": \"11.42.123.111\", 
\"BUCKETNAME\": \"path/Lineite/MAIN\", 
\"QUEUEREGION\": \"\",
\"LOCALPATH\": \"path\"}"

I have verified there is no extra space of enter in the command . Also i tried to to run without \ but same error .

Here is the error i get

2018 : Lambda invocation failed with status: 400\nMon Apr 02 06:45:20 UTC 2018 : Execution failed: Could not parse request body into json: Unexpected character ('Q' (code 81)): was expecting double-quote to start field name\n at [Source: [B@72073757; line: 1, column: 3]\nMon Apr 02 06:45:20 UTC 2018 : Method completed with status: 400\n", "latency": 41, "headers": {} }

When i tried to run from AWS cli it worked but not working from data pipeline.

1 Answer 1

2

You could use a here-document to define a properly formatted JSON so that you don't have to worry about escaping the quotes. Define a function as

jsonDump()
{
  cat <<EOF
{
   "QUEUEURL":"",
   "BUCKETREGION":"us-east-1",
   "FLAGFILE":"",
   "FTPUSERID":"abcd-test-parameter",
   "FTPPATH":"/abcd/Incr1",
   "FTPPASSWORD":"abcd-test-parameter",
   "PARAMETERSTOREREGION":"us-east-1",
   "ISFTP2S3":"false",
   "FTPSERVER":"11.42.123.111",
   "BUCKETNAME":"path/Lineite/MAIN",
   "QUEUEREGION":"",
   "LOCALPATH":"path"
}
EOF
}

and call now the function as below

aws apigateway test-invoke-method --rest-api-id  int836id123 --resource-id  1ukckkkwq1 --http-method POST --body "$(jsonDump)"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.