REST API Development

Hi,

Hope all doing good :slight_smile:

I have created REST API in webMethods. I have created API for get and it is working fine as expected. I have created API for post. I am invoking rest API using pub.client.http by passing the following values.

  1. url               - valid url
  2. method        - post
  3. data/string   - json string
  4. data/encoding - utf-8
  5. headers/Content-Type - application/json

In _post service input, i have jsonString as input and jsonStringToDocument as first step inside the service.
When i run my client service which is invoking rest API, I am getting the error “Missing Parameter jsonString”.

I checked in the rest API, the service was invoked successfully but in the pipeline json string was parsed before the jsonStringToDocument.

Can anyone help me to resolve this issue? Its very urgent.

Thanks in advance!!!

Regards,
Venkat

I believe in the data/string you should pass available API methods for example:

{
“Name”: “National Account Type”,
“Note”: “”,
“KeyDimensions”: [
{
“DimensionName”: “CUSTOMER”,
“DimensionLevel”: “SHIP_TO”
}
]
}

Also make sure headers section set variables:
Content-Type - application/json
Authorization - the token you were provided for oAuth

HTH,
RMG

Hi rmg,

Thanks for your reply!!!

I agree with your points. The problem is i have _post in my rest API. i have input as jsonString, but i am not getting value for that jsonString, instead my whole string is parsed as document.

Consider this example, i am passing the following json string in clinet.http - data/string/

"Student":
 {
    "name":"Venkat"
    "regno":"123456"
 }

then in my rest API _post method, i have input jsonString.

Now, i am expecting the above json string in the input field jsonString. But the actual behavior happening is the json string is internally parsed as document and i am getting studnet document.

 student
     |________  name
     |________  regno 

but i am expecting the string in input field jsonString instead of doucment student.

I hope this example is clear. Thanks in advance.

Regards,
Venkat

Integration Server has inbuilt capability to convert the JSON received into IS document.

Create IS document using the inbuilt service pub.json:jsonStringToDocument and declare the same as input for respective _post service.

Thank you so much for your reply karthikeyan. :slight_smile:

Initially i had doubt and later i realized it is converting internally in IS itself.

Hi Venkat,

Have you created a REST client as well? I am new to webMethods and was trying to create a REST client.
Can you please share what you how you created the it?

Thanks,
Surbhi

Hi,

Is it the same case for XML also?if we pass the XML as request to rest service?will IS convert as document internally?

Regards,
Sakthi

Yes it can process XML rest request and node to document (Json) will be in the pipeline and assuming you have created the IS document for downstream mapping and transformation.

HTH,
RMG