Syntax error updating API version

Hey Monday dev community,
After updating the API version I’m struggling with what seems like a formatting error. I can’t seem to understand what is wrong with the format though.

Here is the error I’m getting:

{
  "errors": [
    {
      "message": "Invalid GraphQL request",
      "extensions": {
        "details": "failed to deserialize the request body into JSON: invalid type: string \"{\\\"columnValue\\\":\\\"29.9772962 31.1324955 4420 148th Ave NE bldg 127, Redmond, WA 98052\\\",\\\"columnId\\\":\\\"location_1\\\",\\\"itemName\\\":7279384567,\\\"myBoardId\\\":4499094121}\", expected a map or null at line 1 column 425",
        "code": "INVALID_GRAPHQL_REQUEST"
      }
    }
  ],
  "account_id": 11622012
}

Here’s the step in the code that’s failing:

import { axios } from "@pipedream/platform"
export default defineComponent({
  props: {
    monday: {
      type: "app",
      app: "monday",
    }
  },
  async run({steps, $}) {

    const bookingID = steps.trigger.event.body.event.pulseId;

    const userItems = await axios($, { 
      url: `https://api.monday.com/v2`,
      method: `POST`,
      headers: {
        'Content-Type': 'application/json',
        'Authorization' : `${this.monday.$auth.api_key}`,
        'API-Version' : '2024-10',
      },
      data: {
        "query": `query {items(ids: [${bookingID}]){name column_values {id value text}}}`  
      } 
    }); 
    
    const projectName = userItems.data.items[0].column_values.find(x => x.id == 'status89').text;

    const locationKey = { 
      "test B127": "test addres 1", 
      "test B124": "test address 2", 
      "test B25": "test address 3", 
    }
    
    if (projectName === null) {
      console.log('no project name');
      return;
    }
    const addressToAdd = `22.2772962 31.1324955 ${locationKey[projectName]}` ?? "22.2772962 31.1324955 Update";
    
    console.log({addressToAdd});

    const data = await axios($, {
      url: `https://api.monday.com/v2`,
      method: `POST`,
      headers: {
        'Content-Type': 'application/json',
        'Authorization' : `${this.monday.$auth.api_key}`,
        'API-Version' : '2024-10'
      },
      data: {
        "query" : "mutation ($myBoardId:ID!, $itemName:ID!, $columnId: String!, $columnValue: String!) { change_simple_column_value(board_id:$myBoardId,item_id:$itemName, column_id: $columnId , value: $columnValue) { id column_values{id text value}} }",
        "variables" : JSON.stringify({ 
          "columnValue": addressToAdd,
          "columnId": "location_1",
          "itemName": steps.trigger.event.body.event.pulseId,
          "myBoardId": 4499094121,
        })
      }
    })
  },
})

I also changed the data section to only have one JSON.stringify. If someone could point me to where the documentation is for how to properly format variables, I’d greatly appreciate it.

data: JSON.stringify({
        query : "mutation ($myBoardId:ID!, $itemName:ID!, $columnId: String!, $columnValue: String!) { change_simple_column_value(board_id:$myBoardId,item_id:$itemName, column_id: $columnId , value: $columnValue) { id column_values{id text value}} }",
        variables : JSON.stringify({
          columnValue: addressToAdd,
          columnId: "location_1",
          itemName: steps.trigger.event.body.event.pulseId,
          myBoardId: 4499094121,
        })
      })

I was able to get this mutation to work by removing variables:

      data: { 
        query: `mutation {change_simple_column_value (board_id: 4499094121, item_id: ${steps.trigger.event.body.event.pulseId}, column_id: \"location_1\", value: \"${addressToAdd}\") {id column_values {id text value}}}`    
      } 

If someone can explain how to better format variables, I’d still like to better understand. Is it less standard to use variables with query?

Hello there @tmanney,

There is no issue with using variables. I just tested this successfully using this:

const myHeaders = new Headers();
myHeaders.append("API-Version", "2025-01");
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", "APITOKEN");

const graphql = JSON.stringify({
  query: "mutation ($myBoardId:ID!, $itemName:ID!, $columnId: String!, $columnValue: String!) { change_simple_column_value(board_id:$myBoardId,item_id:$itemName, column_id: $columnId , value: $columnValue) { id column_values{id text value}} }",
  variables: {"columnValue":"29.9772962 31.1324955 Giza Pyramid Complex","columnId":"location_mkmd8dnr","itemName":111111111,"myBoardId":1212121212}
})
const requestOptions = {
  method: "POST",
  headers: myHeaders,
  body: graphql,
  redirect: "follow"
};

fetch("https://api.monday.com/v2", requestOptions)
  .then((response) => response.text())
  .then((result) => console.log(result))
  .catch((error) => console.error(error));

The cURL for it would be:

curl --location 'https://api.monday.com/v2' \
--header 'API-Version: 2025-01' \
--header 'Content-Type: application/json' \
--header 'Authorization: APITOKEN' \
--data '{"query":"mutation ($myBoardId:ID!, $itemName:ID!, $columnId: String!, $columnValue: String!) { change_simple_column_value(board_id:$myBoardId,item_id:$itemName, column_id: $columnId , value: $columnValue) { id column_values{id text value}} }","variables":{"columnValue":"29.9772962 31.1324955 Giza Pyramid Complex","columnId":"location_mkmd8dnr","itemName":11111111,"myBoardId":12121212}}'

I hope that helps!

Cheers,
Matias

+1 for always use variables