Can some body please let me know how can we exclude a particular header while creating or updating measurement using InventoryApi or MeasurementApi classes.
While using restapi’s we have direct control what headers to include but with sdk API’s I could not find any method
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 MeasurementApi or InventoryApi within the supplied Runnable