Technical Articles
REST Adapter FROM data with Attachment Handling
SAP PI REST adapter can achieved FORM data upload scenarios from HTTP client Application or standard HTML pages.
The target application has Functionality to upload zip file along with FROM data request parameters, making use of this service source system such as ECC or any legacy application post data using integration layer SAP PI.
Once you uploaded file and FROM Data from ECC or legacy application that request reached to PI from there we need post Form data parameters along with attachments and we need get response as success or failures.
Here I had exposed Sender as REST adapter as Binary data handling with-out using Java mapping, initially I had tried in many ways by HTTP_AAE FORM data options and handle using java mapping suggested by blog – (https://blogs.sap.com/2014/09/12/html-form-upload-using-http-plain-adapter-with-java-mapping/) and as format expected by Target Application but it’s getting 400 BAD request from target system.
Finally I have started implementing REST Adapter as Sender Adapter and Receiver used as SOAP adapter. Now I can able to get success Response.
Sender REST Adapter Configurations:
Under Channel section Specify Endpoint that you required.
RestResources mentions as pattern “/”
The other Tabs selection make it as default, no changes required.
Receiver SOAP Adapter configuration:
Please provided your end-point URL and enable options such as – Do Not Use SOAP Envelope , Keep Attachments .
Here in my-case I have proxy tunnel in network so I enabled Configure Proxy, Most have customer not enabled so you need not enable and configure it.
Results:
Post man client I have provided SAP PI URL along with FORM Data parameters and Attachments.
Here we can achieve by using REST/SOAP adapter, I have used SOAP adapter.
The process when you trigger message from PROXY of HTTP application will convert binary format in standard send REST adapter acceptable by Target service binary format.then we can get success response from service.
I hope this blog was helpful to understand how the FORM data and attachments can be used in REST/ SOAP adapter . If you like to learn more, check out the other blogs in the series, accessible from the main blog PI REST Adapter – Blog Overview.
Still not found what you were looking for?
No problem! Just let us know what kind of information is missing and how we can help.
Hi Ganesh,
You can also refer below blog.
https://blogs.sap.com/2019/04/23/csv-multi-part-form-data-upload-as-attachment-using-http_aae-adapter-in-sap-pi-7.5/
Hi Ganesh,
How are you setting the Input message format as 'Binary'.
I don't see such option in drop down list of General Tab -Sender REST Communication Channel).
Hello Rajesh,
Thanks for your comments..The reference blog as mentioned in UDF the same i have implemented UDF as similar alignment to FORM Data but when we are reading attachment the conversation not allowed by Target service.i have tried by add attachment option also but not luck. Even i have tried bind attachment in UDF mapping.
also i have tried by different REST API Java stand-alone java program to able to achieve service. but no luck.
its works when enabling Binary option only.
Thanks
Ganesh Gullipalli.
Hi Ganesh,
Good that it worked by setting the Input message format as ‘Binary' in REST channel.
Let me also kindly check out the PI latest package. Thank you!
Hi Rajesh,
Source will send data to key-values attributes similar to HTML page FORM submit action along with attachment.
Binary option has added on SAP PO 7.5 latest SP. Please verify once SP9 later versions.
Thanks ,
Ganesh G
Hi Ganesh Gullipalli
I read some of your post about rest adapter (I see that you have experience) and I wanted to ask you if you can look at the answers in this post , which I wrote ... I am new to pi and I don't know how to do this. I tried several things but without success ...
https://answers.sap.com/answers/12903884/view.html
Thank you very much, regards.
Hi Ganesh and team
I have a similar requirement Rest to SOAP scenario, where I need to handle Invoice (Json payload) along with PDF attachments.
I have followed above blog.
When you tested from Postman tool, what does the zip file contain ?
can you please share sample payload of it and how you see the request in PO Monitoring. I am struggling to test from Postman tool
I am working on SAP PO 7.5 SP 16
Thanks,
Varun
Hi Ganesh,
I have a similar requirement of REST<-> proxy with attachments, when I am trying to put Data format as Binary its throwing me an error saying -
Returning to application. Exception: com.sap.aii.adapter.xi.routing.RoutingException: Unable to parse XML message payload to extract operation for receiver determinationorg.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 1; Content is not allowed in prolog.
In contrast when I am using data format as XML it is atleast processing the XML file.
Any suggestions?
Regards,
Surabhi
hello,
I read the "REST Adapter FROM data with Attachment Handling " article.
I tried this method and found that there were no "Main request payload name " and "Respond message multipart type " options in my tab .
Is this because my interface verson is outdated?
Please check PO SP, if it is older SP then pls upgrade to latest version of SP.
hello,
the basis tell me that Our Po version is Po 7.5 SP19.
Is there any other reason ?
thank you very much!
hello
After selecting "binary" in "data format", the "main request payload name" and "response message multipart type" options disappear.
Hi Rajesh,
We have similar requirement where the third party needs Multipart form data and body embedded in the request with boundary setup.
Could you please let me know if we can achieve this without Java mapping
Regards,
Padmini