Get request header on start process or task submission

I’m using some api (let’s call it AboveApi) to call everything in camunda. And the AboveApi add some custom headers i.e. user-id to every http request that goes into camunda. I need to get these custom headers to allow camunda to call some others apis (via jsoup). Those external apis returns 401 if request have no such i.e. user-id header. Is it possibble to get the specific header of http request that was made when i.e. task complete action, or started process action?
Ideally via scripting.

1 Like

Why are you using headers vs submitting local variables as part of your task submission?

1 Like

Good question. It’s not my choice. AboveApi is a customer’s tool, and it works only the headers way, and at this point I totally can’t change nothing there.

The camunda rest API is a jaxrs app that is basically a front to the java API. The java API does not know about the actual rest request occurring (as far as I have even seen in the forum or docs).

As a easy scripting solution you could front the camund API with your own app, or if you want to just quickly add a rest endpoint directly in the camunda container with scripting you can use vertx camunda plug-in !

See the readme for a JavaScript example. See vertx.io for more docs

A simple solution could be implementing a servlet filter that reads the headers and makes them available in a thread local. You can then access them from any Camunda delegate code that is called in the context of the request.

Cheers,
Thorben

2 Likes