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