Skip to content
Advertisement

Sending POST request with POSTMAN to Java REST API and getting null values in the xml response

I am creating a REST Service in Java and now I am building the post method which has 2 parameters that has to be inputted as xml in postman (for test) and get a response as xml in java and insert it in database.

For starters I am trying to add the values as Query Params in POSTMAN with key and value. The response is 200 but the xml is CUI=null Mesaj=null

Both values are null even though I added values for both keys in Postman.

How can it see the values? This is the java code:

JavaScript

What should I modify so I can see the parameter values that I send in the post in the xml that postman is generating?

Advertisement

Answer

@PathParam("cui") String cui this line shows that values from client side should be passed as path parameters, not query string, something like this:

correct: /cererepost/some_value

If you want to get them as query string params in server side, change @PathParam("cui") to @QueryParam("cui").

For understading the differences between query string and path variables take alook at this post.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement