ATG REST service not getting raw POST JSON data from POSTMAN

607 views Asked by At

Iam trying to invoke ATG Rest service from POSTMAN, Passing JSON as a raw in the body. Webservice is not getting data,It is coming as null input. But when i pass same input JSON as x-www-form-urlencoded, with key and value pair ,input data(orderJson) is coming fine.

Here is my code in webservice to get input json from POSTMAN.

Rest endpoint:

http://localhost:8080/rest/bean/com/order/CreateOrder/processOrder

Method:

public JSONObject processOrder(String orderJson) throws ServletException,IOException {
 System.out.println("orderJson = " + orderJson);
}

Even when I tried to read raw JSON as below code, the data is not coming:

bufferedReader = req.getReader();

try {
    InputStream inputStream = req.getInputStream();
    if (inputStream != null) {
        bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
        char[] charBuffer = new char[128];
        int bytesRead = -1;
        while ((bytesRead = bufferedReader.read(charBuffer)) > 0) {
            stringBuilder.append(charBuffer, 0, bytesRead);
        }

What should be wrong when we pass input json as raw from body with POST?

Screenshot for x-www-form-urlencoded:

x-www-form-urlencoded

0

There are 0 answers