# Unexpected token \\ in JSON at position 1 in chapter test-the-apis

**URL:** <https://discourse.sst.dev/t/unexpected-token-in-json-at-position-1-in-chapter-test-the-apis/2427>\
**Category:** Chapter Comments\
**Created:** [July 16, 2021, 8:15pm UTC](https://discourse.sst.dev/t/unexpected-token-in-json-at-position-1-in-chapter-test-the-apis/2427 "2021-07-16T20:15:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bhargavInDev](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/bhargavindev/32/1194_2.png) [@bhargavInDev](https://discourse.sst.dev/u/bhargavInDev)\
**Post date:** [July 16, 2021, 8:15pm UTC](https://discourse.sst.dev/t/unexpected-token-in-json-at-position-1-in-chapter-test-the-apis/2427/1 "2021-07-16T20:15:54Z")

</div>

I’m on windows VS code using git bash.  
npx aws-api-gateway-cli-test … --body “{“content”:“helloworld”,“attachment”:“hello.jpg”}”

This is giving me -  
undefined:1  
{\content:\helloworld,\attachment:\hello.jpg}  
^  
SyntaxError: Unexpected token \ in JSON at position 1

The same thing when I tried on cmd prompt gives the same error.

By looking at other solutions on git I tried  
“{“content”:“helloworld”,“attachment”:“hello.jpg”}”

‘{“content”:“helloworld”,“attachment”:“hello.jpg”}’

are still giving me similar errors.

---

<div class="post-metadata">

**Author:** ![danieloi](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/danieloi/32/228_2.png) [@danieloi](https://discourse.sst.dev/u/danieloi)\
**Post date:** [July 23, 2021, 8:40am UTC](https://discourse.sst.dev/t/unexpected-token-in-json-at-position-1-in-chapter-test-the-apis/2427/2 "2021-07-23T08:40:53Z")

</div>

Try removing the JSON.parse from your function.

I notice in prod, you need JSON.parse while you don’t when you’re testing. It might be the other way around but test both cases and see.

---

<div class="post-metadata">

**Author:** ![rdhrty](https://avatars.discourse-cdn.com/v4/letter/r/e495f1/32.png) [@rdhrty](https://discourse.sst.dev/u/rdhrty)\
**Post date:** [December 6, 2021, 7:13pm UTC](https://discourse.sst.dev/t/unexpected-token-in-json-at-position-1-in-chapter-test-the-apis/2427/3 "2021-12-06T19:13:46Z")

</div>

this was a huge pain to troubleshoot but I ended up having success with the following on Windows:

`npx aws-api-gateway-cli-test --username='admin@example.com' --password='Passw0rd!' --user-pool-id='...' --app-client-id='...' --cognito-region='...' --identity-pool-id='...' --invoke-url='...' --api-gateway-region='...' --path-template='/notes' --method='POST' --body='{\"content\":\"helloworld\",\"attachment\":\"hello.jpg\"}'`

Leaving a plain text version below as well for posterity / certainty that the code block formatting doesn’t mess anything up:

npx aws-api-gateway-cli-test --username=‘admin@example.com’ --password=‘Passw0rd!’ --user-pool-id=’…’ --app-client-id=’…’ --cognito-region=’…’ --identity-pool-id=’…’ --invoke-url=’…’ --api-gateway-region=’…’ --path-template=’/notes’ --method=‘POST’ --body=’{“content”:“helloworld”,“attachment”:“hello.jpg”}’

Make sure to note that you will have to plug in the appropriate values for your env for the `...`'s I have in the example snippet. Main issues I noticed from the content provided in the course ([Secure Our Serverless APIs](https://serverless-stack.com/chapters/secure-our-serverless-apis.html)) were issues with aligning the quotes _(i.e. opening and closing quotes potentially getting misplaced / unintentionally plugged in during copy/paste etc.)_ and the space in ‘hello world’ getting bungled up by the terminal upon attempting to interpret it.

_Only advice would be to be careful about copying pasting anything that will affect any of the quotes throughout the snippet (i.e. plug the values directly into the quotes instead)_

Hope this helps someone down the line…! ^^^
