Skip to Content

Test SAP API Business Hub APIs with Curl

0 %
Test SAP API Business Hub APIs with Curl

Test SAP API Business Hub APIs with Curl

October 7, 2021
Created by Meredith Hassett
January 12, 2017
Try out an SAP API locally on your machine.

You will learn

  • How to use command line tools like Curl and jq REST/ODATA APIs locally.
QR code


  • Make sure you have the command line tools Curl and jq installed.
  • Windows instructions: Curl and jq
  • MacOS/Unix instructions: jq (Curl should already be available)

You have already discovered the SAP API Business Hub and accomplished testing an API on the website. In this tutorial, you will learn how to use command-line tools like Curl and jq to test REST/ODATA APIs locally on your machine.

Step 1: Navigate to the User Management API

Go to and navigate to the Campaign API.

Campaign API
Log on to answer question
Step 2: Generate sample API call code

Select GET/CampaignCollection method under API Reference. Glance through the GET/CampaignCollection to understand the parameters. The SAP API Business Hub provides you with starter code in a variety of languages and tools for each API.

Get/CampaignCollection method

Choose Try Out to proceed further.

Try Out

The API call starter code is available in various languages like JavaScript and Swift. You will be using the Curl code in this example.
Choose Code Snippet and select Curl to view the generated code. This personalized snippet already includes your unique API key.

Curl Code

Copy the highlighted Curl code to the clipboard.

copy the code
Log on to answer question
Step 3: Run sample API call code

Paste the content of the clipboard in a terminal or command line window.
Hit Enter to run the command. It may take a few seconds before data is seen on your screen.

You can use CTRL+C to stop the command from running.

terminal with code copied

You’ll notice that the output is not formatted. For this, you can pipe the output of Curl to jq to format it.

terminal with code and jq added

The formatted output data displays the parameters for GET method.

Formatted output data
Log on to answer question
Step 4: Limit the number of results

You can limit the number of results to be displayed by adding the $top value provided in the Parameter section of the GET/CampaignCollection method. As $ is not allowed in the URL, it is encoded as %24 as per URL encoding.

limit the results
--url \

After your command line prints out 3 results, it should stop running.

text editor with limited test results

If you get a Curl: no match error, try wrapping your URL in single quotes.

It may be easier to make edits to your Curl code in the text editor rather than directly in the command line.

Log on to answer question
Step 5: Add multiple parameters to the API call

Besides the $top parameter, you can add multiple parameters to the Query String of your API call.
Now add in the 2nd parameter for $select. You only want the StatusText and Status for the top 3 users. You can delaminate values in the select array using a comma(,). However, a comma is not a character allowed in a URL. The ASCII encoded value is %2C.

This changes the second line of the command to.

--url "" \

The & character indicates to the command line that a new command in coming. You need the command line to interpret the & as part of the URL.

Run the assembled command in the terminal.

text editor with parameter added

You have now learnt how to use code snippets productively.

Copy the entire result set and paste the result in the text box below.

Next Steps

Back to top