Correct flow service input for JSON?

Hello,

I have combed the forums but cannot find an answer. I am using Postman to POST to a flow service that was created as a REST resource. If I set the type as “text/plain” in Postman I can set the input to the flow service as an Object named “contentStream”. I can then use pub.json:jsonStreamToDocument to convert to a document and do what is needed from there.

If in postman I set the type as “application/json” this no longer works and I see a “jsonStream missing” error most likely from the stream coming in as empty when mapped to the input of the StreamToDocument service.

I have found a few tutorials but none cover what type of input I am supposed to be setting for the flow service. I even found this guide here[url]How to create a REST service in webMethods Integration Server - SOA rocks! that said ““IS automatically unwraps the JSON payload and converts it to IS documents”.” To me this sounds like a Document should be the input but that doesn’t work either.

Can anyone share what the proper input / first steps are for a flow service to accept the POSTing of application/json content?

Thanks!

Here you go


IS Rest Input for Post method.PNG

2 Likes

Thank you, this is exactly what I was looking for! Got mine working.

Cheers!!!

I got most of this to work however I am unsure how to accept an array in the JSON as input.

For example if you had:

{
“cars”: {
“Nissan”: [
{“model”:“Sentra”, “doors”:4},
{“model”:“Maxima”, “doors”:4}
],
“Ford”: [
{“model”:“Taurus”, “doors”:4},
{“model”:“Escort”, “doors”:4}
]
}
}

I have tried setting the equivalent of “Nissan” on my end to “Document List” but it does not seem to come into the service at all. Thank you in advance

Stange. I just copy pasted your request input, and I can see document list coming on IS
Postman_Request.PNG
IS_Pipeline.PNG

I think I found my problem. I am saving the pipeline and then manually loading it / restoring later to run. The pipeline file will load however elements under the Document list type do not. This is why I was thinking they were not coming into the service in the first place. Seems to be an issue with webMethods not properly restoring a list from pipeline.

If we don’t know JSON input structure(Dynamic input) then how can i capture JSON data in webMethods service. as i remember we can take JSON input as object then we can convert into document.
could you please share steps if you have idea?

You need not necessarily declare a structural document as input in your service. Integration Server Content Handler automatically sends you the document as per your dynamic JSON into your service.

Is it not work around for this, do I need to know the structure of the json payload?

I like to have a generic rest-service that can receive a json payload and publish to UM without knowing the payload structure.