Long_text encoding

i am trying to integrate from our git into monday and need to transfer the git’s ticket description into a long_text column.

as the description can include markdown, it will include hashes and other special characters that seem to break the graphQL api (e.g. hashes are comments in graphql etc.)

should be easy to fix if I knew the expected encoding for long_text api input strings. But could not find any.

working in nodejs with raw data.

First try (which works api wise but does not result in proper display of the texts):

`
 ${mutationName} : change_multiple_column_values(
            board_id: $boardid, item_id: 1273911846,
            column_values: "{ 
                \\"name\\":\\"${gitlabIssue.title}\\",
                \\"text\\":\\"${gitlabIssue.title}\\",
                \\"long_text\\":\\"${encodeURIComponent(gitlabIssue.description)}\\"        
            }"
        )
        {
            id
            name
        }
`

before I try all string encodings known to humankind: where did I miss it in the docs?

cheers

Its not an encoding issue.column_values is a JSON string, so you create your object for the value, then stringify it and use that resulting string.

Additionally, I’d investigate GraphQL variables rather than string composition or template strings for the query. This lets you define variables in the query, and then pass a variables object in the graphql request - and the server takes care of substitution.

You would put the stringified value of the object for the column_values in the variable.

By using JSON.stringify rather than trying to create the JSON manually it will ensure everything is escaped as needed.

const columnValuesObject ={
   name: gitlabIssue.title,
   text: gitlabIssue.title,
   long_text: gitlabIssue.description,
};


const variables = {
   boardId: "1231352435423",
   itemId: "123123245234",
   columnValues: JSON.stringify(columnValuesObject), //you could create columnValueObject within JSON.stringify()
};

const query =  `${mutationName} : mutation($boardId: ID!, $itemId: ID!, $columnValues: JSON!) change_multiple_column_values(board_id: $boardid, item_id: $itemId, column_values: $columnValues) {
      id
      name
 }`;
const response = await monday.api(query, {variables});
1 Like

thank you! That solves my issues.

The fact that for mutations i have to send a json instead of using fieldnames is confusing me a lot.

1 Like