I have seen this question asked a few times here but never with the “ character.
For clarification this is not my code that is putting out the error, this is what I get back from an api.
My first try:
I use https://reqbin.com/ and the request works perfectly (what i did)
My second try:
I decide to move this to running programmatically to use in development.
On ios there is an app called scriptable this allows you to run javascript
I use the code
let req = new Request("https://support.readaloud.app/ttstool/createParts");
req.method = "post";
req.headers = {"Content-Type": "application/json" };
var data = '[{"voiceId":"Amazon British English (Brian)","ssml":"<speak version=\"1.0\" xml:lang=\"en-GB\">' + "Hello" + '</speak>"}]';
req.body = JSON.stringify(data);
let res = await req.loadString();
Where res should respond with ["id"]
like reqbin
Unfortunately it does not and returns
SyntaxError: Unexpected token " in JSON at position 0
at JSON.parse (<anonymous>)
at createStrictSyntaxError (/home/ec2-user/readaloud/webservices/node_modules/body-parser/lib/types/json.js:160:10)
at parse (/home/ec2-user/readaloud/webservices/node_modules/body-parser/lib/types/json.js:83:15)
at /home/ec2-user/readaloud/webservices/node_modules/body-parser/lib/read.js:128:18
at AsyncResource.runInAsyncScope (node:async_hooks:201:9)
at invokeCallback (/home/ec2-user/readaloud/webservices/node_modules/raw-body/index.js:231:16)
at done (/home/ec2-user/readaloud/webservices/node_modules/raw-body/index.js:220:7)
at IncomingMessage.onEnd (/home/ec2-user/readaloud/webservices/node_modules/raw-body/index.js:280:7)
at IncomingMessage.emit (node:events:538:35)
at endReadableNT (node:internal/streams/readable:1345:12)
If you can help I would greatly appreciate it.
Thanks