Parsing Error: No error on playground, error in JavaScript

This is my Javascript:

const query5 = 'mutation {create_column (board_id: 1163502014, title: "ding", column_type: status, defaults: "{\"labels\":{\"0\":\"Working ffffonit\",\"1\":\"Done\",\"2\":\"Stuck\",\"14\":\"\",\"12\":\"\",\"7\":\"\"},\"labels_colors\":{\"0\": {\"color\":\"#fdab3d\",\"border\":\"#E99729\",\"var_name\":\"orange\"},\"1\":{\"color\":\"#00c875\",\"border\":\"#00B461\",\"var_name\":\"green-shadow\"},\"2\": {\"color\":\"#e2445c\",\"border\":\"#CE3048\",\"var_name\":\"red-shadow\"},\"14\": {\"color\":\"#784BD1\",\"border\":\"#8F4DC4\",\"var_name\":\"dark-purple\"},\"12\": {\"color\":\"#FF158A\",\"border\":\"#E01279\",\"var_name\":\"dark-pink\"},\"7\": {\"color\":\"#579bfc\",\"border\":\"#4387E8\",\"var_name\":\"bright-blue\"}}}" ) {id}}';
        fetch("", {

        method: 'post',


        body: JSON.stringify({

            'query' : query5



        .then(res => res.json())

        .then(res => console.log(JSON.stringify(res, null, 2)));


I copy and past the mutation exactly into the API playground and it works. However, when I run the mutation through the JavaScript fetch I get:

“Parse error on “:{” (STRING) at [1, 101]”

Okay so fixed it using \\\" everywhere instead of \" also escaping the first quote for the defaults parameter value.

really would like a better way to do this if anyone knows the correct way


found the easier way:

`mutation {create_column (board_id: 1163502014, title: “dong”, column_type: status, defaults: ${JSON.stringify(JSON.stringify(settings))} ) {id}}`

where settings is a JSON object.


1 Like

Hey @adeutsch :wave:

I’m glad you were able to find a solution for this! I can confirm that you will need to use some layers of JSON.stringify in your JS code in order to pass the values correctly. One thing that might help you avoid this much escaping is using variables. You might have already been aware of this, but our JavaScript Quickstart also includes some info on using GraphQL variables:

Using GraphQL Variables to create a new item - API Quickstart JS

For example:

variables: JSON.stringify({"value" : JSON.stringify("SAMPLE")})

I hope this helps at all! I’ve also moved the topic to the Developers section, please feel free to explore the resources there :slight_smile:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.