0

I need to retrieve the json text input of the body of the post request..

I use javax.ws.rs.*

This is my code ..:

 @POST @Consumes(value = MediaType.APPLICATION_JSON) @Produces(MediaType.TEXT_PLAIN) public Response postProduct(final Product product) { try { // I want to retrieve the json text of the post request body here. if (null == product) // In case of an empty "product" { return Response.status(Response.Status.BAD_REQUEST).entity("No data").build(); } .... 

This is the json body that I want to retrieve in my method :

 { "productNumber":"65421", "ExpirationDate":"2023-12-31", "supplier":"yyy" } ``` Thanks a lot in advance.. 
2
  • Hello Najlae, welcome to StackOverflow! What does the Product object contain? Your issue is that you do not know how to extract data from the Product object. Could you share documentation/code on the product object? Where does product come from? Commented Jan 27, 2023 at 1:26
  • You may want to reformat the title to be a question: "How to read json file from a post-request in Java?" Just by formatting the title, google gives me lemons(this might be your answer): stackoverflow.com/questions/53340128/… Commented Jan 27, 2023 at 1:28

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.