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: 
taranam
Contributor
7,306
In continuation to my last blog  “Unboxing Custom Business Object Continued: Calling REST API inside logic” where I discussed about how to consume APIs from CBO ; next important topic for Technical and Functional people is Testing APIs since APIs play vital role in SAP S/4HANA Cloud Implementation as for sending /receiving information you will use APIs.
API stands for Application Programming Interface; API acts as a messenger which takes a request and tells the target system what to do. And returns the response back to the requesting system.


The first question that comes to mind is How can I test API and check if the API meets my requirement and what all data is returned by it ?

Well you can test REST /SOAP APIs using any of the following ways:

  • Using SAP API Business Hub: Recommended and easiest option for functional to test the APIs

  • Using tools like POSTMAN: Middle ware and development teams generally test calls using POSTMAN

  • From Code (Custom field and logic / Custom BO app)
    Any Prerequisite: Yes, set up of Communication arrangement in S4C system for all three options.


Let's see how these options can be used for API testing :

•   Using SAP API Business Hub

This is the simplest way to test APIs and the easiest tool for functional to test the API and validate the API data. SAP gives provision to configure your own S4C system as well in the API Hub .
You can filter the APIs based on solution like SAP S/4HANA Cloud and find the API for your requirement example I am looking for API to return Billing header and item information. By default, SAP also Provides Sandbox which can be used to test API. And you can configure your own system to test the API with your data.



Once you click on Configure Environment ; fill in below details to configure your own S/4HANA Cloud system.



   Once you have configured your S/4HANA Cloud system ;then in API environment drop down select your configured system and then you can try out any entities of the API to see the data.


     Click on the Try out option as shown below for the entity you want to test.


  It will show the different parameters options that you can use to filter the data. Click on Execute option.


      After that you will see the response . Code tells if the response was successful or not ; in this case 200 means Success.



            In response you can see the data of API as well ; this helps to figure out which fields hold data for your case.For more details on using SAP API Business Hub you can refer here.




  • Using POSTMAN:


You can also use the Postman tool to test the APIs if the Communication arrangement is in place. This tool is very helpful from developer perspective as they can test the APIs. Mostly its used by Middle ware teams to test the calls and checking metadata etc.






    • You need to have the Inbound Communication arrangement set up in your S/4HANA Cloud system and you will need the Communication username and password to give in Postman Authentication

    • For GET request you just need to call the GET method of an API with API URL that you will find in the API Hub along with basic authentication (here username and password of your Communication user in S4C)
      Example for Billing header information from API Hub check the request URL AND replace the sandbox name with your system name.








  • For using POST request you need to fetch the x-csrf-token using GET request .




         Once you have the x-csrf-token ; same can be used in POST request .

  • Using Custom Code :


You can also call the APIs from CBO Logic / from Custom field and logic app by writing the logic to check the setup of Communication arrangement and then calling the REST API. For this we need to have the Outbound Communication arrangement set up in place. This we have seen in my last blog post as well.


Summary: In this we covered how Technical and Functional teams can test the APIs while working on S/4HANA Cloud system. In my next post we will see my learnings /observations while working with new Custom CDS View Fiori app in Cloud 2008,refer  SAP S/4HANA Cloud: Key Takeaways on CDS Views

6 Comments
Labels in this area