Skip to Content
Technical Articles
Author's profile photo Sumandeep Kaur

Create an API in SAP API Management to upload file without using Postman

Hello Everyone!

            This is my first blog post. For the past few months, I have been working on APIs as part of my work. An API is a software intermediary that allows two applications to talk to each other and also various policies can be applied to these APIs. I have created APIs in ‘Create in API designer’ component of SAP API Portal and tested various pre-packaged APIs to understand how they behave.

Introduction:

This blog post describes how to design API to upload file from your system to target system without using Postman. I have configured one iflow in SAP CPI with HTTPS on sender side and FTP adapter on receiver side. I have triggered that iflow from SAP API management to send file to target end point of iflow.

Prerequisites:

Access to SAP API Portal and SAP CPI (Cloud Platform Integration).

Host server url.

Target server url.

Steps to be followed to upload file.

Step 1: Configure iflow.

Configure an iflow in SAP CPI with HTTPS on sender side and FTP adapter on receiver side. FTP adapter can be configured to send file to DriveHQ as it provides virtual FTP server to store files. Deploy the iflow and copy the end point.

Step 2: Create API

Create an API in ‘Create in API designer’ section in SAP API Portal in OpenAPI Specification 3.0.1 and add target server url of iflow end point. This API will consume Multipart/form-data and will upload file.

Note: Keep the Post method end point same as CPI iflow end point and don’t add that end point in target server url, it will add Post method end point and trigger an iflow.

Step 3: Try Out in API Portal

Now save and deploy the API and try uploading the file in try out option in ‘Resources’. Click on choose file to select file from your system.

Note: Add header as Authorization and value Basic Base64 encoded credentials same as your CPI credentials.

Step 4: Execute and file will be sent.

Click on execute, your CPI iflow will be triggered and file will be sent through FTP adapter to DriveHQ.

Note: Files with .txt format can be downloaded and opened. But files with .pdf and .docx formats have to be edited in DriveHQ and add extension of file format (.docx,.pdf ) before downloading.

Conclusion: SAP API Management supports API-led integrations across various parties and systems. It’s very interesting and simple to design APIs in Create in Designer section in OpenAPI Specification 3.0.1.  This API helps to send file from your system to target system without using Postman.

Assigned Tags

      13 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Arshi .
      Arshi .

      Thanks Suman for this wonderfully well written blog. Really Helpful 🙂

      Author's profile photo Sumandeep Kaur
      Sumandeep Kaur
      Blog Post Author

      Thanks Arshi

      Author's profile photo pallavi chaudhury
      pallavi chaudhury

      Hi Suman Its such a nice blog.

      Author's profile photo Sumandeep Kaur
      Sumandeep Kaur
      Blog Post Author

      Thanks Pallavi

      Author's profile photo Sandeep Kaur
      Sandeep Kaur

      Very nice . Liked your work

      Author's profile photo Ramya P
      Ramya P

      Hi Suman,

      Well written blog, Suman. It's indeed interesting to design APIs using the API designer.

       

      Thanks,

      Ramya

      Author's profile photo Sumandeep Kaur
      Sumandeep Kaur
      Blog Post Author

      Thanks Ramya, yes its very interesting to design APIs in API designer.

      Author's profile photo Nandhini Ramasamy
      Nandhini Ramasamy

      Hi Suman,

      The blog is really helpful and interesting..Thank You..

      Author's profile photo Sumandeep Kaur
      Sumandeep Kaur
      Blog Post Author

      Thanks Nandhini

      Author's profile photo Ameer Khan
      Ameer Khan

      Hi Sumandeep Kaur ,

      Thanks for sharing such a wonderful blog 🙂

      There is a requirement where the base64 format files need to be sent from third party system to S4 system via SAP APIM.

      Is it possible to achieve this via SAP APIM using the above approach?

      Thanks,

      Ameer

      Author's profile photo Sumandeep Kaur
      Sumandeep Kaur
      Blog Post Author

      Hi Ameer,

      You can use CPI to send files from third party to S4 system and expose the iflow in SAP API Management. Well, I am also exploring SAP API management if I will come across this type of scenario, I 'll surely let you know.

       

      Regards

      Author's profile photo vinduja N
      vinduja N

      Thank you Suman for this blog

      Author's profile photo Sumandeep Kaur
      Sumandeep Kaur
      Blog Post Author

      Thanks Vinduja.