Cancel
Showing results for 
Search instead for 
Did you mean: 

Mindsphere SDK - Null error code when filter has an invalid field

Experimenter
Experimenter

I am using Mindsphere Java SDK.

 

In the SDK, when I execute the following code (field timestamp2 does not exist) 

 

 

eventClient.getEvents("timestamp", String.format("{\"timestamp2\":{\"between\":\"[%s,%s]\"}}", begin, end)
.replace("[", "%5B")
.replace("]", "%5D"))

The error stack trace does not show what I missed.

 

 

Exception in thread "main" com.siemens.mindsphere.sdk.core.exception.MindsphereServiceException
	at com.siemens.mindsphere.sdk.iot.event.apiclient.EventClient.getEvents(EventClient.java:146)
	at com.siemens.mindsphere.sdk.iot.event.apiclient.EventClient.getEvents(EventClient.java:465)
...
Caused by: org.springframework.web.client.HttpClientErrorException: 400 
	at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:94)
	at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:79)
	at org.springframework.web.client.ResponseErrorHandler.handleError(ResponseErrorHandler.java:63)
	at org.springframework.web.client.RestTemplate.handleResponse(RestTemplate.java:772)
	at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:725)
	at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:699)
	at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:616)

 

In order to see more information about the error (in this example "Field <timestamp2> is not filterable"), I have to configure my IDE to break when an uncaught exception is throw.

 

UncaughtExceptionBreak.png

 

 

 

 

 

 

 

 

 

 

 

 

The same situation happens in other scenarios. Thus, I suggest to extract error information into errorMessage / errorStatusCode.

 

 

1 REPLY
Highlighted

Re: Mindsphere SDK - Null error code when filter has an invalid field

Creator
Creator

Hello

 

I am not sure if you are still facing this issue. But this issue is fixed in the SDK 1.2.0 version.

 

Thanks!