How to check if the measurement got created in JAVA SDK

Product/components used and version/fix level:

Cumulocity Production

Detailed explanation of the problem:

Hi, I created a measurement using MeasurementRepresentation but how would I get to know if it is actually created or if it caused any issues or not. Is there any way I can verify?

 public boolean createMeasurement(MeasurementRepresentation measurementPayload) {
        measurementApi.create(measurementPayload);
        return true;
    }

Best Regards,
Samanyu

Hey Samanyu,

the create method will return back the MeasurementRepresentation from Cumulocity. So as long as you don’t get any error and the returned Object is not null, you should be save to assume that the operation was successfull.

Cheers,
Mario

1 Like

In detail the create method will throw a SDKException in case of an error.

1 Like

Hi Mario,

So, basically I can check for null but regarding the error. How can I check if it gave any error or not? Do I need to wrap it around a try catch block?

Cool Name btw.

Thanks & Regards,
Samanyu

Okay I can catch the SDK Exception, is it valid for all the methods? Can I catch SDK Exception for all the methods?

Yes, the exception also contains the HTTP status code.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.