camunda/camunda-8-js-sdk

Response code 415 (Unsupported Media Type) on Zeebe REST completeUserTask

Closed this issue · 4 comments

Hello!

Zeebe StandaloneBroker v8.5.0
c8 -

Problem!

const zeebeRest = c8.getZeebeRestClient();
var params = {
userTaskKey: key
}
zeebeRest.completeUserTask(params);

It's not work!

Error
err: {
"type": "HTTPError",
"message": "Response code 415 (Unsupported Media Type) (request to http://rms:8080/v1/user-tasks/2251799813691816/completion)",
"stack":
HTTPError: Response code 415 (Unsupported Media Type) (request to http://rms:8080/v1/user-tasks/2251799813691816/completion)
at gotBeforeErrorHook (D:\SOURCE\RMS\node_modules@camunda8\sdk\dist\lib\GotHooks.js:26:17)
at Request._error (D:\SOURCE\RMS\node_modules\got\dist\source\core\index.js:1198:31)
at D:\SOURCE\RMS\node_modules\got\dist\source\core\index.js:1284:23
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
"name": "HTTPError",
"code": "ERR_NON_2XX_3XX_RESPONSE",
"timings": {
"start": 1718237290195,
"socket": 1718237290196,
"lookup": 1718237290197,
"upload": 1718237290224,
"response": 1718237290399,
"end": 1718237290403,
"phases": {
"wait": 1,
"dns": 1,
"tcp": 27,
"request": 0,
"firstByte": 175,
"download": 4,
"total": 208
}
},
"statusCode": 415,
"source": [
"Error",
" at gotErrorHandler (D:\SOURCE\RMS\node_modules\@camunda8\sdk\dist\lib\GotHooks.js:15:11)",
" at Array. (D:\SOURCE\RMS\node_modules\got\dist\source\create.js:67:24)",
" at iterateHandlers (D:\SOURCE\RMS\node_modules\got\dist\source\create.js:89:50)",
" at got (D:\SOURCE\RMS\node_modules\got\dist\source\create.js:117:20)",
" at got. [as post] (D:\SOURCE\RMS\node_modules\got\dist\source\create.js:224:42)",
" at D:\SOURCE\RMS\node_modules\@camunda8\sdk\dist\zeebe\zb\ZeebeRESTClient.js:63:46",
" at process.processTicksAndRejections (node:internal/process/task_queues:95:5)"
]
}

But FETCH Working!

var params = {
method: 'POST',
headers: {'Content-Type': 'application/json;charset=utf-8'},
body: JSON.stringify({variables: {}, action: "string"})
}
await fetch("http://rms:8080/v1/user-tasks/" + key + "/completion", params);

I think it's a problem with the HTTP headers.

Thanks for reporting this @aim-dot-antares.

Any chance that you can provide me with a repo with the configuration files and a startup script so that I can reproduce this locally?

Hi @jwulf

I made a test private repository.
Sent an invitation. zeebe-test-rest
And I checked this project locally.
The error is also reproduced locally

Released in 8.6.5.

The issue was that headers were not being added to REST methods, so they were missing the authorization header and the content encoding header.

The unit test gets the usertaskId for the call from the Tasklist API.

There are plans for other methods - see here: camunda/issues#789