Passing Headers while creating External Task client

Hi,
At the engine side we have few external service tasks, the engine is secured.
I want to subscribe to those external tasks
I am creating the client like this →
camunda.bpm.client:
base-url: http://localhost:8080/engine-rest

Along with this I need to pass header
Can anyone suggest how can I pass that.

Hello @vaishaliarora ,

welcome to the forum. For Basic Auth, it is done like this (I assume you use the spring boot starter external task client):

camunda.bpm:
  client:
    base-url: http://localhost:8080/engine-rest # The URL pointing to the Camunda Platform Runtime REST API
    basic-auth: # Configure if REST API is secured with basic authentication
      username: demo
      password: demo

For more information about the project, please find the source code here:

If your use case cannot be covered with the starter right now, consider using the “normal” external task client:

I hope this helps

Jonathan

Yeah for Basic auth I am using the same.
But I want to pass some header like “Role”,“id” some headers.

do you know how can I set that here?

Hello @vaishaliarora ,

I am not sure what these headers should help you with. The REST API will not be able to do anything with these as long as you do modify it?

What should be purpose of these headers?

Jonathan

These are for authentication at the engine’s end

Authenticating against what? The engine will just need a username and a password.

so I have added few roles there … if the role in the header matches to the role defined in the engine it should be able to execute the BPMN

This sounds like a custom implementation. Usually, you would assign the user to a group and the group to Authorization objects.

Yeah this is a custom implementation.
I am seeing this sort of error at my client end
Caused by: org.apache.http.client.HttpResponseException: status code: 401, reason phrase: {“timestamp”:“2021-07-14T09:52:32.389+0000”,“status”:401,“error”:“Unauthorized”,“message”:“Required header is missing (x-bpm-role).”,“path”:"/engine-rest/external-task/fetchAndLock"}

In this case, I would suggest you use the “normal” external task client. This client can be configured to also use other kinds of headers. You can find a link in my first response.

okay … I will try that out.

Thanks Lukas :slight_smile:

1 Like

Hi vaishali

I am facing same issue can you guide me please !

Thanks

Yes Sure,
Can you elaborate a bit about your issue

Hi Vaishali

I wanted to add query-param in base url.

Example:
Suppose My Base Url Is “http://localhost:8080/engine-rest/external-task/fetchAndLock
I want to add query-param in that .

after adding query-param base url will be “http://localhost:8080/engine-rest/external-task/fetchAndLock?apikey=123wer

how i can achive this

Thanks
Deepak