Skip to content
Advertisement

How to pass JSON Object and return Object from Spring rest controller

I have an entity class like below:

JavaScript

Here is my rest controller:

JavaScript

I have two questions:

How can I send the report as well as Http Status back as a response?

How to send the data to controller?

I have created the following test case:

JavaScript

When I run this the test case failed and I was able to pin point the issue :

JavaScript

So I am guessing I am not sending this values in right way

For Description POJO is below:

JavaScript

Here is the values that is being send: {“desc”:”org.restservice.Description@1213ffbc”, “outputType”:”TIFF”,”inputType”:”PDF”,”nameBytes”:”src/test/resources/sampleDocuments/test_16.pdf”,”inputName”:”98111″}

How can I send that as Object if I am sending a Map of <String, String> in body? Is there any other way to send that object to controller?

Advertisement

Answer

To return the status and also the object you can try to do it like this:

JavaScript
Advertisement