Using ThingsBoard CE 4.3.1.3 with thingsboard-client-ce 4.3.1.3, an exception occurs in the generated client method:
handleOneWayDeviceRPCRequestV2WithHttpInfo
Exception
com.fasterxml.jackson.databind.exc.MismatchedInputException:
Cannot deserialize value of type `java.lang.String` from Object value
(token `JsonToken.START_OBJECT`)
Cause
The response body is a JSON object containing the rpcId, but the client attempts to deserialize the entire response directly into a String:
String responseValue = responseBody.isBlank()
? null
: memberVarObjectMapper.readValue(
responseBody,
new TypeReference<String>() {}
);
return new ApiResponse<String>(
localVarResponse.statusCode(),
localVarResponse.headers().map(),
responseValue
);
This fails when the API response is an object such as:
Proposed fix
Extract the rpcId field from the JSON response instead:
String responseValue = responseBody.isBlank()
? null
: memberVarObjectMapper.readTree(responseBody).get("rpcId").asText();
return new ApiResponse<String>(
localVarResponse.statusCode(),
localVarResponse.headers().map(),
responseValue
);
This correctly handles the object response and returns the rpcId as the expected String.
Expected result
handleOneWayDeviceRPCRequestV2WithHttpInfo should successfully deserialize the RPC response and return the rpcId without throwing MismatchedInputException.
Using ThingsBoard CE 4.3.1.3 with thingsboard-client-ce 4.3.1.3, an exception occurs in the generated client method:
handleOneWayDeviceRPCRequestV2WithHttpInfoException
Cause
The response body is a JSON object containing the
rpcId, but the client attempts to deserialize the entire response directly into aString:This fails when the API response is an object such as:
{ "rpcId": "..." }Proposed fix
Extract the
rpcIdfield from the JSON response instead:This correctly handles the object response and returns the
rpcIdas the expectedString.Expected result
handleOneWayDeviceRPCRequestV2WithHttpInfoshould successfully deserialize the RPC response and return therpcIdwithout throwingMismatchedInputException.