Shopify GraphQL Variable Body error with {{{jsonSerialize record}}}

Hey There,

Why does using mapper 2.0 and {{{jsonSerialize record}}} work perfectly in the Build Variables preview but when I run the flow I get an invalid JSON error “An invalid JSON is sent in the request.body, error: please ensure that you have wrapped all JSON property names in quotes. details: Expected ',' or '}' after property value in JSON at position 372 (line 1 column 373)”??

This is how the documentation says to build a body and it should work. I’m having to hand code my variable bodies which is super annoying.

Am I doing something wrong??

Can you try just {{jsonSerialize record}}? So 2 curly braces.

Thank you guru….

I get a warning in the preview.. “Evaluated result is not valid JSON. Expected property name or '}' in JSON at position 1 (line 1 column 2)”
But the flow works.
The jsonSerialize helper prepends the 3 braces when I use it too.

Thanks Tyler!

Yeah the GraphQL connector is a little finicky because the 3 GraphQL specific fields end up concatenating to one field in the backend (HTTP request body). So the merging of those 3 to 1 and correctly escaping quotes etc get tricky.

1 Like