Enterprise Resource Planning Blogs by Members
Gain new perspectives and knowledge about enterprise resource planning in blog posts from community members. Share your own comments and ERP insights today!
cancel
Showing results for 
Search instead for 
Did you mean: 
nirmalmehta1706
Explorer

Let me start the story with the requirements I had then Ill come to the approach I opted and in the journey it is possible that I may have done some mistakes so I'll add a humble request to all my senior fellow to add there expertise in this blog, This will help everyone to get more insights.

Scenario:

We had to integrate an application which had a requirement to connect to and External AI application that has exposed some API to us with some documentation.

Challenge:

From the initial thoughts this looks easy, it just an API, as so as I thought , but as I mentioned above  "documentation" gave us the real challenge. To complete all the call we had to send the multipart/form-data to this receiver.

Through the help of documentations we are able to successfully send the data from Postman. but when we tried to send it from CPI we faced challenges which lead us to the solution. So next I am sharing the steps we performed to send the form-data 

Clearly, if such problem arrives instantly we come to SAP community and search for the answer, we found https://community.sap.com/t5/technology-q-a/sending-form-data-from-sap-cpi/qaq-p/12613755 solution that gives us a way and describe what form-data is and how well it can be passed- but solution given here was to change the type of data itself which was not a choice for us.

At least we got half way on understanding the way multipart/form-data will be constructed. To understand more about  terms and functionality please refer this wonderful article https://community.sap.com/t5/technology-blogs-by-sap/what-is-form-data-and-how-to-send-it-from-sap-c... by mattisebastian this will help us to create the exact frame of data we need to post and in correct way and  how much important the envelope is.

 

Solution:

To Solve this it is very important to understand the few terms like Content-type, Content Disposition, Accept, Boundary and all the fields that are required in Form data.

nirmalmehta1706_0-1715115917415.png

To understand this format we had to mimic the Postman request we were directly send to API.

So we created a CPI Artifact to trace the look of the form data and we were able to get the exact same results as in screenshot , but we have to append an actual JSON which had a list of json data in format of string <binary> (File). And that was actually a file upload (that we were doing from postman).

nirmalmehta1706_1-1715116249725.png

till now if we send request without this JSON file, the AI app was accepting the request but with an error as no real data was found in envelope.  

So now we had to find a way to send this file in Realtime to the receiver. and for that we tried various ways like to store the payload in data store and creating Tables and so on.

But issue persisted when we have to send it in Realtime. So to get a bit more Idea we again sent this request from Postman to CPI and traced it.

nirmalmehta1706_2-1715116678371.png

To get these headers understanding we also put some effort to create Multipart/Form-data from MIME script  from the blog https://community.sap.com/t5/technology-blogs-by-sap/part-6-simplify-integration-of-data-from-sap-s-... from  divyamary

and we created following results:

nirmalmehta1706_3-1715117131718.png

So now we know how the file data look like and what part in payload we are missing, as we had to send the binary data we changed the header Content-Transfer-Encoding: 7bit to 

Content-Transfer-Encoding: Binary and same goes for file name.

and that's it.. it worked! Just some correction on payload customization and headers and we created multipart/form-data in Content Modifier only.

Briefs  and Take-aways:

  • Mimic Postman Hits in CPI by artifacts , hit to CPI and traces the payload.
  • Set the Headers correctly specially Content-type and Boundary(specially spaces 🙂 )
  • Check if there is any media type for the type of data you are trying to send to receiver and set it correctly.
  • You can also try the MIME multipart script to simulate the outcome, it will give you some correct data formats and header options.
  • Add those  steps and create a right payload in Content modifier.
  • After creating the form data always try to create a right envelope with right boundary  (that worked for us)
  • Send with right adaptor configurations and ... it will be success.

Following are some key blogs from experts which we referred. a big thank them .

 

It was just my first blog so it will definitely have some misses, please add you comments and feedback so that ill improve. 

Sap community is a Big sea and its just a drop that I added.

 

Thank you.

  

 

 

Labels in this area