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:
- Inject
ContextService<MicroserviceCredentials>into your bean - Get the current context from it using the
contextService.getContext()method - Clone this context without the application key
- Enter this modified cloned context using
contextService.runWithinContext() - Execute your desired requests using
MeasurementApiorInventoryApiwithin the suppliedRunnable