How to: Creating a Destination in SAP for Making Requests to HTTPS Secured APIs
This article walks through how to securely integrate SAP with external systems using REST APIs, emphasizing best practices like authentication, token management, and API design patterns to ensure reliable, scalable, and secure cross-platform communication.

This is a walkthrough showing how to create a https destination in SAP in order to be able to call an external API within your ABAP code.
The Problem
When you just plug in an https URL for an API endpoint and just fire away, you will probably receive an exception relating to HTTP_COMMUNICATION_FAILURE. However, there isn’t much explanation to understand why specifically the communication with the API failed.
. . .
cl_http_client=>create_by_url(
EXPORTING
url = lv_url
IMPORTING
client = http_client
).
. . .
http_client->receive(
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
others = 4
).
. . .The Solution
We will set up a destination connection so that we can replace cl_http_client=>create_by_url( ) with cl_http_client=>create_by_destination( ).
Steps
- Create the Destination Connection
- Add SSL Certificates
- Test the Connection
Create the Destination Connection
- Go to Transaction SM59.
- Click Create.
In the Create Destination popup, give your destination a name and select connection type G - HTTP connection to external server.

Figure 1: Creating an RFC Destination in Transaction SM59
Technical Settings
- Description 1: Add a short explanation of the destination
- Host: This is the domain of the API. Example: switchedon.bowdark.com
- Port: Use 443 by default unless someone specifies otherwise
- Path Prefix: This is optional. But if there is a specific path for the API that that doesn’t change you can enter that here
Logon & Security
To utilize SSL/TLS with the outgoing client request, select the following settings:
- SSL: Active
- SSL Certificate: ANONYM SSL Client (Anonymous)
At this point, if you click the “Connection Test” button, the test should fail because we have not yet provided the details about the SSL certificates to the system.
Uploading SSL Certificates to STRUST
To negotiate SSL/TLS handshakes within API calls, we'll need to download the SSL certificates from the API endpoint. If the API provider hasn't provided these certificates, you can download them by performing the following steps:
- Open your web browser
- Navigate to the URL of the API you are working with
- Click the lock symbol at the beginning of the URL
- Click connection is secure
- Click connection is valid (a pop up window will appear)
- Click into the Details tab
- Select the first certificate
- Click Export certificate
- Save in a place you can remember to get to
- Repeat the Export with the remain certificates in the Certificate Hierarchy chain
Once the certificates are downloaded, we can upload into the AS ABAP trust store by performing the following steps:
- Go to Transaction STRUST
- Expand the folder “SSL client SSL Client (Anonymous)”
- Click on your system’s name
- In the “Certificate” section, click the bottom left button “Import certificate”
- Click Add to Certificate List
- Repeat for remaining certificates
Connection Testing
To test connections, go back to Transaction SM59 and select the connection you created previously. Click the Connection Test button and compare the results. You should see a result that the test was successful. You should now be able to utilize the destination in your ABAP code by using it to create an HTTP client instance like this:
. . .
cl_http_client=>create_by_destination(
EXPORTING
destination = 'EXAMPLE_DESTINATION_NAME'
IMPORTING
client = http_client
).
. . .


