Basically i have 2 files: PDF and json files. I can use service pub.file:getFile into stream form.
Then what do you suggest the next step using:
pub.flow:transportinfo
pub.mime:***
Basically i want to re-create the POSTMAN as I put in screen capture using pub.http.
I tried to put data which contains args for files and thread_input like below:
If you want to post the data to HTTP using pub.client:http then you don’t need pub.flow:transportinfo.
Rather you create the form-data using services below and post the mimestream.
pub.mime:createMimeData
pub.mime:getEnvelopeStream
pub.mime:addMimeHeader
pub.mime:addBodyPart ( this should be repeated for each of your data one for PDF and other for JSON)
Once mimeObject is ready you can post it to via pub.client:http service.
Refer Integration_Server_Built_In_Services_Reference.pdf for more details
when you call: [quote=“Fanny_Sari1, post:5, topic:228929”]
pub.mime:addMimeHeader
[/quote]
for pdf and json, make sure you have the Content-Type header populated.
Is “key” a required header for your target system? header contains name/value pairs. “key” is normally not the name of the key.
I think the required one is “thread_input” for json file and “files” for the pdf like in the postman.
I will try to give:
*) thread_input = json filename.
*) files = pdf filename.
Passing json file name as value is invalid. You should be passing the object data loaded from getFile service as value. preferable load as string in getFile service.
In PostMan original request object is a file in json format and content-type is set as application\json.
So in wM you try to create name/value pair as thread/input & json object(string from getFile) along with content-type as application\json.
That way when you invoke the service won’t fail with invalid content-type.
Current request you are making, you are passing thread-input as a string with value as filename i.e. json filename, that is wrong.
Please check what actually required to pass then do pass accordingly.
Let us know if our understanding of your requirement itself is wrong.
pub.mime:addBodyPart
(add string to mimeHeader, set name as “Content-Disposition” and value to “form-data; name=thread_input”)
(set contenttype to “application/json”)
pub.mime:getEnvelopeStream
(set createMultipart to “yes”)
Map mimeData=>Content-Type to headers=>Content-Type
pub.client:http
(map envStream to data=>mimeStream)
And I managed to get the correct response in partner URL.
Thank you for Firoz and Wang Tong for your great help.
Really appreciate it.
I noticed that you did not mentioned about how you passing Files param (key/value) in the above logic in the mimeHeader??. Hope it was just a miss in the sudo logic description above?
I have the same scenario of sending a .txt file and and Json file as an attachment in REST API call.Basically wanted to replicate the below postman scenarion in http call in wM.