Exclude a particular header in MeasurementApi or InventoryApi which creating or updating

Most relevant headers including the X-Cumulocity-Application-Key header are controlled through the context. So in order to change or remove a header you’ll have to create a new context and run your request within it.

The context is managed through com.cumulocity.microservice.context.ContextService<C> I don’t have a concrete example that I can share but here is a basic approach that you can take:

  1. Inject ContextService<MicroserviceCredentials> into your bean
  2. Get the current context from it using the contextService.getContext() method
  3. Clone this context without the application key
  4. Enter this modified cloned context using contextService.runWithinContext()
  5. Execute your desired requests using MeasurementApi or InventoryApi within the supplied Runnable
1 Like