We are facing the issue, where we are not getting online statues for a device even though the device is getting the measurements every minute. We are using cumulocity sdk to send the measurements to the deviceas shown below:
MeasurementRepresentation createMr = new MeasurementRepresentation();
createMr.set("measurement",xyz);
createMr.setSource(xxx);
createMr.setType(xxx);
createMr.setDateTime(dateTime);
measurementApi.create(createMr);
If we use RestApi it is working fine. We had posted the question https://techcommunity.cumulocity.com/t/device-availability-status-not-changing-when-measurments-created-using-sdk-api/3883/2
and got few replies.
One was removing the X-Cumulocity-Application-Key header from the request and sending the empty PUT requests to update the status manually. For the first one, we don’t have sdk support to remove the X-Cumulocity-Application-Key header and second I tried id did not work. Since it is an immediate issue which we have to fulfill the client request, can some body provide a solution for this one
As explained in your last question, the microservice SDK provides means to remove the X-Cumulocity-Application-Key header. It just doesn’t work through the MeasurementApi class itself but through the context.
As Philipp has mentioned this can be solved by using the Microservice SDK and updating the context in which you execute the creation of a new measurement:
In this we don’t not use the app key as part of the combined key for retrieving said context again. This may lead to the same context being returned again without the changes made. In order to circumvent this behaviour you can also reset the XSRF token to a value of your choice (ex: “PLACEHOLDER”) since it is not relevant when sending requests from a microservice to Cumulocity within the same environment.