Forum Academy Marketplace Showcase Pricing Features

Quotation marks stopping API call

Hello. I’ve been running into a bizarre issue using the API connector with the Shopify API.

Any time I send over a call to create a product, update a description, etc, the call stops and can’t be completed any time a user includes quotation marks " in the data being sent over.

I know this is because the JSON that’s being sent also uses quotes to break up information. I’ve been (rather inelegantly) using Find & Replace to remove quotes from information being sent, but it’s not ideal. Is there some way to format this information being sent so that it can process a call including the quotation marks?

For example, here is the call to create a new product on Shopify:

{
“product”: {
“title”: “”,
“body_html”: “”,
“vendor”: “Vanessa Jane”,
“product_type”: “”,
“images”: [
{
“src”: “”
}
]
}
}

Now, let’s say my user includes some information in their product description such as:

This product is 72" long

The call will go through, and then stop with an error as soon as it sees the quotes.

Same question.

How to allow users to input quotes for the text in the API call?

When you do the API action try :formatted as JSON safe after the value you are feeding it

2 Likes

This YouTube is very helpful. 3 minutes. Replace quotes.

1 Like

What am I doing wrong here?

The screenshot is of the prompt input i am sending to openAI API. I’ve tried adding :formatted as JSON safe to every part of the input and also separating the inputs in the api call.

Thanks again!

What’s the response your getting from the API? What error?

1 Like

HTTP 400 error

It appears that format as JSON safe isn’t being applied when I inspect.

Thanks for the quick response

Screenshot your actual API call in the API Connector

1 Like

I tried adding format as JSON safe in the API connector, too. Maybe I messed up.

I tried passing the values into the API connector individually (not in one prompt input like above). Same error.

Second screen shot

Looks like it worked according to that last screenshot?

That’s the response from the API connector, not with the passed in values from the previous screen shots.

formatted as JSON safe is adding quotes to the input:

And quotes aren’t allowed. Can’t figure out what I’m doing wrong

Remove all the :formatted JSON safe, seems like if you do \" for every " it makes it safe

The user can type whatever, but then where you are making the API call do :find & replace and replace " with \"

True, that works.

Additionally, I need to replace \ with \ in the prompt.

When I replace " with " the find and replace above removes the replaced " and still throws an error. Looks like \\ when passing into the api.

@will.nft.works Do :find & replace again after that and replace \ with \\

I have no idea maybe someone will chime in here with like a solution that covers everything but try that :joy:

Thanks @tylerboodman

Work around I found. Replace " with a single quote ’ and the \ with \

Really appreciate your replies. Hopefully this can help someone else

2 Likes

I was having the same issue recently. I tried a bunch of the stuff mentioned here. Finally I just replied replacing \ with \ in ‘find and replace’ and that seemed to work