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.
jwulf
August 8, 2022, 2:55am
2
Hi @chrisallen ,
Try escaping some quotes into the string, so:
{
"taskId": {{taskid}},
"variables": [{
"name": "foo",
"value": "\"bar\""
}]
}
Does that work?
Josh
2 Likes
Hi @jwulf . Yes that works, thanks. As an additional test, I also added a string variable ad-hoc to a user task in Tasklist for C8, and saw that it complained that the string was not āJSON stringā, and suggested a pop up editor where I put double quotes around it. That helped give me some context.
Thanks.
Hello,
I have actually the same problem using TaskList GraphQL API with Node.JS server.
My code is :
const body = {
operationName: null,
query: `mutation { completeTask(taskId: "${idTask}", variables: [{ name: "VARTEST", value: "TestValue" }]) { id, name, taskDefinitionId, processName, creationTime, completionTime, assignee, taskState, sortValues, isFirst, formKey, processDefinitionId, candidateGroups }}`,
variables: {}
}
try {
const response = await fetch(ENDPOINT, {headers: {'Content-Type': 'application/json', "Authorization": "Bearer ..."}, method: 'POST', body: JSON.stringify(body)})
const data = await response.json()
console.log("data=", data);
} catch(err) {
console.log(err);
}
Error is :
data= {
errors: [
{
message: "Unrecognized token 'TestValue': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')\n" +
' at [Source: (String)"TestValue"; line: 1, column: 10]',
locations: [Array],
path: [Array],
extensions: [Object]
}
],
data: null
}
Query work with no āvariablesā attribute or setted to ā[]ā
What am I doing incorrectly?
Thanks a lotā¦