Hi,
I'm struggling using an array of strings in an POST request.
I have a temporary state (list_attachments) where I push the tokens:
I've to use this array in the raw body of the POST request.
I'm sending the array in the additional scope.
send_email_to_store.trigger({
additionalScope: {
email_body: richTextEditor_EmailContent[i].value.replaceAll('<p>', '<br>').replaceAll('</p>', ''),
attachments: list_attachments.value.join()
}})
The api body is like this:
{
"ticket": {
"subject": "xxx",
"comment": {
"html_body": "{{email_body}}",
"uploads": [{{attachments}}]
},
The problem I've is with the quotes for the array values.
{
"request": {
"url": "https://xxx.zendesk.com/api/v2/tickets.json",
"method": "POST",
"body": "{\"ticket\":{\"subject\":\"xxxx\",\"comment\":{\"html_body\":\"AAAA\",\"uploads\":[\"[\"yKlv5gIxfuSsfXFbizomB9IL3,n3J5aPnnE1wcTugKaJTIruYXz\"]},}}",
With this code are missing the double quotes in the middle.
Changing the join as:
list_attachments.value.join('","')
still doesn't work, because is adding \
in front of them:
\"uploads\":[\"rDr7o2okWiQ4N5HEOK8rQxlZ7\\\",\\\"G5wdwWwSozaFul5iRRVX7KZ8M\"]}
If I change the body request hardcoding the array, it's working properly.
{
"ticket": {
"subject": "{{xxx}}",
"comment": {
"html_body": "{{email_body}}",
"uploads": ["rDr7o2okWiQ4N5HEOK8rQxlZ7","G5wdwWwSozaFul5iRRVX7KZ8M"]
},
This is how the request appears:
{
"request": {
"url": "https://italist.zendesk.com/api/v2/tickets.json",
"method": "POST",
"body": "{\"ticket\":{\"subject\":\"xxx\",\"comment\":{\"html_body\":\"AAAA\",\"uploads\":[\"rDr7o2okWiQ4N5HEOK8rQxlZ7\",\"G5wdwWwSozaFul5iRRVX7KZ8M\"]}
What I'm doing wrong?
Thanks