Kenny
05/30/2022, 7:02 PMnpx aws-api-gateway-cli-test --username <mailto:test@gmail.com|test@gmail.com> --password 12345Foo! --user-pool-id us-east-1_I8XLnM67Q --app-client-id 44hqn436m45aa92j9vkh7pjdfn --cognito-region us-east-1 --identity-pool-id us-east-1:966cd055-29d0-4f48-ba65-3326cf9dea63 --invoke-url <https://d8cdv8pdh4.execute-api.us-east-1.amazonaws.com> --api-gateway-region us-east-1 --path-template /notes --method POST --body "{\"content\":\"h\",\"attachment\":\"h.jpg\"}"
But I get an error saying {\ SyntaxError: Unexpected token \ in JSON at position 1
I have even tried this
npx aws-api-gateway-cli-test --username <mailto:test@gmail.com|test@gmail.com> --password 12345Foo! --user-pool-id us-east-1_I8XLnM67Q --app-client-id 44hqn436m45aa92j9vkh7pjdfn --cognito-region us-east-1 --identity-pool-id us-east-1:966cd055-29d0-4f48-ba65-3326cf9dea63 --invoke-url <https://d8cdv8pdh4.execute-api.us-east-1.amazonaws.com> --api-gateway-region us-east-1 --path-template /notes --method POST --body '{"content":"d","attachment":"hello.jpg"}'
Ross Coundon
05/30/2022, 7:46 PMbody = JSON.parse(argv.body);
Therefore, it could be a dodgy character in your body, maybe the double quotes are invalid, I don’t think you need to escape the quotes in there, so your second example looks like it should work.
I just copied and pasted your example and I get
Authenticating with User Pool
Getting temporary credentials
Making API request
{
status: 500,
statusText: 'Internal Server Error',
data: { message: 'Internal Server Error' }
}
Where do you see the JSON parse error?Kenny
05/30/2022, 7:47 PMKenny
05/30/2022, 7:47 PMAuthenticating with User Pool
Getting temporary credentials
Making API request
undefined:1
{content:d,attachment:hello.jpg}
^
SyntaxError: Unexpected token c in JSON at position 1
at JSON.parse (<anonymous>)
at makeRequest (C:\Users\kenny\AppData\Local\npm-cache\_npx\ea84c6478cf14779\node_modules\aws-api-gateway-cli-test\index.js:179:17)
at C:\Users\kenny\AppData\Local\npm-cache\_npx\ea84c6478cf14779\node_modules\aws-api-gateway-cli-test\index.js:152:5
at C:\Users\kenny\AppData\Local\npm-cache\_npx\ea84c6478cf14779\node_modules\aws-sdk\lib\credentials.js:124:23
at C:\Users\kenny\AppData\Local\npm-cache\_npx\ea84c6478cf14779\node_modules\aws-sdk\lib\credentials.js:212:15
at processTicksAndRejections (internal/process/task_queues.js:77:11)
Kenny
05/30/2022, 7:48 PMRoss Coundon
05/30/2022, 7:48 PMKenny
05/30/2022, 7:48 PMKenny
05/30/2022, 7:48 PMRoss Coundon
05/30/2022, 7:48 PMKenny
05/30/2022, 7:49 PMKenny
05/30/2022, 7:49 PMRoss Coundon
05/30/2022, 7:49 PMnpx aws-api-gateway-cli-test --username <mailto:test@gmail.com|test@gmail.com> --password 12345Foo! --user-pool-id us-east-1_I8XLnM67Q --app-client-id 44hqn436m45aa92j9vkh7pjdfn --cognito-region us-east-1 --identity-pool-id us-east-1:966cd055-29d0-4f48-ba65-3326cf9dea63 --invoke-url <https://d8cdv8pdh4.execute-api.us-east-1.amazonaws.com> --api-gateway-region us-east-1 --path-template /notes --method POST --body '{"content":"d","attachment":"hello.jpg"}'
Kenny
05/30/2022, 7:49 PMRoss Coundon
05/30/2022, 7:50 PMKenny
05/30/2022, 7:51 PMRoss Coundon
05/30/2022, 7:52 PMKenny
05/30/2022, 7:52 PMRoss Coundon
05/30/2022, 7:54 PMKenny
05/30/2022, 7:54 PMFrank
Jay
Jay
Kenny
05/31/2022, 2:19 PMKenny
05/31/2022, 2:19 PMKlaus
05/31/2022, 3:32 PMKenny
05/31/2022, 3:32 PMKenny
05/31/2022, 3:32 PMKlaus
05/31/2022, 3:32 PMKlaus
05/31/2022, 3:32 PMKenny
05/31/2022, 3:33 PMKlaus
05/31/2022, 3:54 PMbash
in powershel + then sending the command (which is using WSL in that case)Klaus
05/31/2022, 3:55 PMecho
in Powershell ) simply seems to failKenny
05/31/2022, 4:27 PMbash
then
npx aws-api-gateway-cli-test --username <mailto:test@gmail.com|test@gmail.com> --password 12345Foo! --user-pool-id us-east-1_I8XLnM67Q --app-client-id 44hqn436m45aa92j9vkh7pjdfn --cognito-region us-east-1 --identity-pool-id us-east-1:966cd055-29d0-4f48-ba65-3326cf9dea63 --invoke-url <https://d8cdv8pdh4.execute-api.us-east-1.amazonaws.com> --api-gateway-region us-east-1 --path-template /notes --method POST --body '{"content":"d","attachment":"hello.jpg"}'
??Klaus
05/31/2022, 5:29 PMKenny
05/31/2022, 5:36 PMKlaus
05/31/2022, 5:37 PM$ bash Welcome to Ubuntu 20.04.4 LTS (GNU/Linux 5.10.43.3-microsoft-standard-WSL2+ x86_64) ...
$npx aws-api-gateway-cli-test --username <mailto:test@gmail.com|test@gmail.com> --password 12345Foo! --user-pool-id us-east-1_I8XLnM67Q --app-client-id 44hqn436m45aa92j9vkh7pjdfn --cognito-region us-east-1 --identity-pool-id us-east-1:966cd055-29d0-4f48-ba65-3326cf9dea63 --invoke-url <https://d8cdv8pdh4.execute-api.us-east-1.amazonaws.com> --api-gateway-region us-east-1 --path-template /notes --method POST --body '{"content":"h","attachment":"h.jpg"}'
Kenny
05/31/2022, 5:37 PMKlaus
05/31/2022, 5:38 PMKenny
05/31/2022, 5:38 PMKlaus
05/31/2022, 5:39 PMKlaus
05/31/2022, 5:41 PMKenny
05/31/2022, 5:41 PMKenny
05/31/2022, 5:42 PMwsl --install -d Ubuntu
Klaus
05/31/2022, 5:42 PMKlaus
05/31/2022, 5:45 PMKlaus
05/31/2022, 5:51 PMKlaus
05/31/2022, 5:56 PMKenny
05/31/2022, 6:06 PMJay
Klaus
05/31/2022, 9:25 PM