How to get RESTful POST/PUT request body(payload) in webMethods?

In GET(_get) service,I can get input params from $resourceID and $path ,but in POST/GET,I can not find a variable in WM,anyone can give me some suggestion, many thanks!
PS:WM version is 8.2.

After one day’s trial,I figure out this issue :x

Correct steps as follows:
1.fill http request body with varableName=+json string,eg:bookInfo={…},although very strange,but it works.,
2.encode the string generate in step 1
3.select an encode,eg:utf=8
4.in WM flow,set input as bookInfo~

OK thanks for the updating back on this thread.

Sorry for no helping hands.

HTH,
RMG

I successfully get body variables without setting input variable when using POST and PUT.
But it doesn’t work for DELETE and GET even when variables are in input.

Yee Fong, do you get body variables with POST and GET or only with POST?

GET/DELETE should also have body/bytes in the pipeline .

Is that it not the case?

HTH,
RMG

Hello,

No, I use pub.flow:tracePipeline in the REST services to have a look on the pipeline and there is a contentStream only when I use POST & PUT. With the same request but using GET or DELETE I have no contentStream in pipeline.

When using only _default service with tracePipeline this is the same behaviour.

I’m on 9.6

Can you please try to use the getTransportInfo service and debug the pipeline (ofcourse streams cannot be saved or shown in the pipeline)

HTH,
RMG

getTransportInfo doesn’t display body content, what do you want to check with it?

Exemple with POST:
[1185803]2014-12-19 11:42:51 CET [ISP.0090.0002C] — END tracePipeline —
[1185802]2014-12-19 11:42:51 CET [ISP.0090.0008C] 0 $path {java.lang.String} = ‘1546’
[1185801]2014-12-19 11:42:51 CET [ISP.0090.0008C] 0 $resourceID {java.lang.String} = ‘123’
[1185800]2014-12-19 11:42:51 CET [ISP.0090.0008C] 0 contentStream {com.softwareag.is.enterprisegateway.net.HttpInputStream} = ‘com.softwareag.is.enterprisegateway.net.HttpInputStream@9f31d67’
[1185799]2014-12-19 11:42:51 CET [ISP.0090.0008C] 0 var2 {java.lang.String} = ‘54’
[1185798]2014-12-19 11:42:51 CET [ISP.0090.0008C] 0 var1 {java.lang.String} = ‘12’
[1185797]2014-12-19 11:42:51 CET [ISP.0090.0001C] — START tracePipeline [19/12/14 11:42] —

Exemple with GET:
[1185810]2014-12-19 14:56:36 CET [ISP.0090.0002C] — END tracePipeline —
[1185809]2014-12-19 14:56:36 CET [ISP.0090.0008C] 0 $path {java.lang.String} = ‘1546’
[1185808]2014-12-19 14:56:36 CET [ISP.0090.0008C] 0 $resourceID {java.lang.String} = ‘123’
[1185807]2014-12-19 14:56:36 CET [ISP.0090.0008C] 0 var2 {java.lang.String} = ‘54’
[1185806]2014-12-19 14:56:36 CET [ISP.0090.0008C] 0 var1 {java.lang.String} = ‘12’
[1185805]2014-12-19 14:56:36 CET [ISP.0090.0001C] — START tracePipeline [19/12/14 14:56] —

In attachments 2 screenshots of request and response


Perhaps my method would be useful for someone.
I have wM version 9.9, but I suppose it may works in some early version.
So, let’s look at the types of queries in order…

  1. GET
    This is very simple case without any difficulties.
    1.1) Request
    Use URL to send Resource ID into wM service. E.g. use http://localhost:5555/rest/restSvc/client/123 to request information about Client number 123.
    1.2) Processing
    You may use Java or Flow services.
    You may use separated handlers GET\POST\etc. or DEFAULT handler. In the last case use pub.flow:getTransportInfo to define a request type (get\post\etc.).
    1.3) Response
    Set response code by means of pub.flow:setResponseCode.
    Convert your Document (Document Type) to JSON String thru pub.json:documentToJSONString.
    Set response thru pub.flow:setResponse.
  2. DELETE
    This case is similar previous, but usually the response consists of header only.
  3. POST
    3.1) Request
    Set Content-Type: application/json.
    Set data in json format, e.g.
    {
    “client”: {
    “id”: “123”,…}
    }
    Call your REST service http://localhost:5555/rest/restSvc/client/123
    3.2) Processing
    Unfortunately, you can take json data without any tricks from Java service only. E.g. use code
    IDataMap idm = new IDataMap(pipeline);
    IData customer = idm.getAsIData(“client”);
    But previously add into Java service pipeline variable “client” type of interesting Document Type.
    3.3) Response
    Set response code by means of pub.flow:setResponseCode.
  4. PUT
    This case is similar previous.

P.S. Useful site to validate JSON https://jsonformatter.curiousconcept.com/

My GET rest service is not populating $resourceID and $path. When I log these values, it shows null. Please help.