Google App Script: Mutation query doesn't run

I have the following code for sending an API request from my Google App Script:

function sendApiRequest(query)
{
  var sendQuery = JSON.stringify(query);
  var options = {
  'method' : 'post',
  'headers' : {
      'Content-Type': 'application/json',
      'Authorization' : key
  },
  'payload' : sendQuery
};
  var response = UrlFetchApp.fetch(apiUrl, options);  
  Logger.log(response);
  return parseResponse(response);
}

When I’m trying to send a mutation query in order to update an item, I’m using the following query:
mutation {
change_multiple_column_values (board_id: 20178755, item_id: 200819371, column_values: “{"status": {"index": 1}}”) {
id
}
}

The problem is that in the column_values: "{\"status\": {\"index\": 1}}") section I need to have double quotes wrapping my JSON.Stringfy values, which I’m just unable to make it happen.
The JSON Stringfy process either add escape or remove the quotes.

Could some please help?

Hey @asafnevo - If you are using NodeJs you can use JS Template String ex:
mutation { change_multiple_column_values (board_id: 20178755, item_id: 200819371, column_values: “${yourQuery}”) { id } }

there should be backtick (`) before the opening double quotes and after closing double quotes
can’t put the backtick here in the comment box I hope monday.com will fix this.

1 Like

Hey there @vcdizon04

Just to clarify, when you mention you are not able to put a backtick in the comment section, are you referring to the monday.community forum? If so, I’m afraid this is related to the platform we are using to host the forum and it is not related to the API itself. Does that make sense? :slightly_smiling_face:

-Alex