How to insert/update String variable with GraphQL on completeTask

I am using the following complete task query.

mutation completeTask ($taskId: String!, $variables: [VariableInput!]!) {
    completeTask (taskId: $taskId, variables: $variables) {
        id
        name
        taskDefinitionId
        processName
        creationTime
        completionTime
        assignee
        variables {
            id
            name
            value
            previewValue
            isValueTruncated
        }
        taskState
        sortValues
        isFirst
        formKey
        processDefinitionId
        candidateGroups
    }
}

My GraphQL variables are:

{
  "taskId": {{taskid}},
  "variables": [{
    "name": "foo",
    "value": 7
  }]
}

And it works fine. But this does not work.

{
  "taskId": {{taskid}},
  "variables": [{
    "name": "foo",
    "value": "bar"
  }]
}

I get an “Unrecognized type” error.

“message”: “Unrecognized token ‘bar’: was expecting (JSON String, Number, Array, Object or token ‘null’, ‘true’ or ‘false’)\n at [Source: (String)“bar”; line: 1, column: 4]”,

What am I doing incorrectly?

Thanks.

Hi @chrisallen ,

Try escaping some quotes into the string, so:

{
  "taskId": {{taskid}},
  "variables": [{
    "name": "foo",
    "value": "\"bar\""
  }]
}

Does that work?

Josh

2 Likes