on 2023 Jan 10 9:16 AM
HI,
I am trying to learn with a youtube video on how to consume rest api in abap. Obviously I am missing some information as the connection doesnot happen due to some problem. Someone suggested to use RSDEMO_HTML_VIEWER to check if there is a http connection setup in the system to call websites.
I have access to two systems,
First: ECC system ABAP ver 7.5 with MS SQL as database.
When I execute the RSDEMO_HTML_VIEWER , it doesnot have any response to any url.
Second: S4HANA system.
When I execute the RSDEMO_HTML_VIEWER , with google.com and press button , it opens google.com front page and same with any other website url.
But my program that is a copy of some youtube video doesnot work. Following is my progam code. Please let me know if there are any corrections.
REPORT zdemo_rest_api.
DATA: lv_url type string,
co_timeout_default type i value 15.
*lv_url = 'https://services.odata.org/TrippinRestierService/(S(h2dgad34g3lj3yhmfbla0loy))/people'.
lv_url ='https://jsonplaceholder.typicode.com'.
* Step 1 : Use the cl_http_client class and static method to create http client
cl_http_client=>create_by_url(
EXPORTING
url = lv_url
IMPORTING
client = data(obj)
EXCEPTIONS
argument_not_found = 1
plugin_not_active = 2
internal_error = 3
pse_not_found = 4
pse_not_distrib = 5
pse_errors = 6
others = 7
).
IF SY-SUBRC = 0.
* Step 2 : If the client object is created successfully, make a request
obj->send(
EXPORTING
timeout = 15
EXCEPTIONS
http_communication_failure = 1 " Communication Error
http_invalid_state = 2 " Invalid state
http_processing_failed = 3 " Error when processing method
http_invalid_timeout = 4 " Invalid Time Entry
others = 5
).
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Step 3 : After sending request ask for response
obj->receive(
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
others = 4
).
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Step 4 : Get Data
data(result) = obj->response->get_cdata( ).
* Step 5 : Check if any data is passed successfully
cl_abap_browser=>show_html(
EXPORTING
title = 'First Rest Api Consumption'
html_string = result
).
ENDIF.
Errors :
500 Native SSL Error
SSL handshake with jsonplaceholder.typicode.com:443 failed: SSSLRC_CONN_CLOSED (-10)
Remote Peer has closed the network connection
SapSSLSessionStartNB()==SSSLRC_CONN_CLOSED
My question:
1. What are the basic steps FOR SETTING UP THE SYSTEM to consume an api in ABAP.
2. What and how to do certificate setup/config?
3. Does the Admin need to give any permissions for user role to access HTTP ?
Thank you very much.
Request clarification before answering.
User | Count |
---|---|
88 | |
10 | |
9 | |
8 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.