I have an REST client:
import org.restlet.representation.ObjectRepresentation;
import org.restlet.data.MediaType;
ObjectRepresentation<ApprovalResponse> objectRepresentation = (ObjectRepresentation<ApprovalResponse>) cr.post(approvalRequest, MediaType.APPLICATION_JAVA_OBJECT);
And a Spring Boot Service RESTful api:
import org.springframework.http.MediaType;
@PostMapping(value = "/rest/approvals-submit")
public @ResponseBody ApprovalResponse submit(@RequestHeader(name="Authorization") String token, @RequestBody ApprovalRequest approvalRequest) {
System.out.println("jwt token: "+token);
System.out.println(approvalRequest.getMessageToEvaluator());
ApprovalResponse approvalResponse = new ApprovalResponse();
approvalResponse.setApprovalId("Test approvalResponse from micro service");
return approvalResponse;
}
The client calls the API successfully. i.e. the System.out.println(approvalRequest.getMessageToEvaluator());
is printed out successfully.
Problem
My issue is that the response object is not getting back to the REST client.
Error Messages
Rest client
org.restlet.resource.ResourceException: Not Acceptable (406) - The resource identified by the request is only capable of generating response entities which have content characteristics not acceptable according to the accept headers sent in the request
Server/Api
Resolved [org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation]
Question
So I think these errors are because the MediaTypes are not defined correctly. Do you know what they should be defined as?