webMethods 10.1 Receiving Payload Http POST Request JSON

What is the best approach to use the webMethods REST Resource v2 implementation with WM IS 10.1.
I am facing a lot of challenges with receiving the Http POST JSON Requests.

I always get the values in “jsonBytes”.
What if I wanted to have those values directly as single JSON string from input?
Does Wm 10.1 hase any such feature available.
It is blocking my current development work for the client.

The term “best” is subjective. To know what would be “best” for your situation would require additional detail. :slight_smile:

In any case, if you want a string, just call pub.string:bytesToString.

Review the details of the extended property watt.server.http.jsonFormat for additional info.

Hello Mandar,

Adding more to the above, please review this standard resolution notes captured from a another KB article:-

===============
Starting with version 9.0.1, Integration Server supports JSON. When a request with a Content-type of application/json is received, IS uses the JSON content handler which generates a completely different input pipeline. The actual input pipeline that is created depends on the value of the watt.server.http.jsonFormat system property, which can be overridden on a per-request basis. This property was added to 9.5.1 in a fix, so customers need a certain fix level to get this additional functionality. Please see the fix readme for details on how watt.server.http.jsonFormat works, but briefly:

  • if jsonFormat is “stream”, pipeline will contain “jsonStream”
  • if jsonFormat is “bytes”, pipeline will contain “jsonBytes”
  • if jsonFormat is “parsed”, the JSON document in the request body will be parsed and the structure of the
    pipeline will map to the structure of the JSON document, i.e. there will be a name/value pair in the
    pipeline for each name/value pair in the document

Customers can -

  1. Take the approach that you suggest in your previous comment;
    OR
  2. Set jsonFormat to “bytes” and turn jsonBytes into a string with “new String(jsonBytes)” or by calling pub.string:bytesToString;
    OR
  3. Set jsonFormat to “parsed” and all the name/value pairs in the document will be available directly in the pipeline.
    ===============

You can try it out.

HTH,
RMG