Easy to use HTTP agent and login manager with request/response handling.
NO WARRANTIES, MIT License
Initialize an HTTP agent and set header fields:
DATA(agent) = zcl_http_agent=>create( ).
" Optionally set headers
agent->global_headers( )->set(
iv_key = zif_http_agent=>c_header-accept
iv_val = zif_http_agent=>c_content_type-json ).
agent->global_headers( )->set(
iv_key = zif_http_agent=>c_header-content_type
iv_val = zif_http_agent=>c_content_type-json ).
agent->global_headers( )->set(
iv_key = zif_http_agent=>c_header-user_agent
iv_val = `abap 7.5` ).
Get and set authorization tokens:
DATA(host) = 'api.github.com'.
IF zcl_http_login_manager=>get( host ) IS NOT INITIAL.
agent->global_headers( )->set(
iv_key = zif_http_agent=>c_header-authorization
iv_val = zcl_http_login_manager=>get( host ) ).
ENDIF.
Get request:
DATA(response) = agent->request( url = 'https://api.github.com/emojis' ).
IF response->is_ok( ) = abap_false.
message = |Error { response->code( ) }|.
ENDIF.
Put request with payload:
DATA(response) = agent->request(
url = 'https://myserver.com/'
method = zif_abappm_http_agent=>c_method-put
payload = json ).
IF response->is_ok( ) = abap_false.
message = |Error { response->code( ) }|.
ENDIF.
SAP Basis 7.50 or higher
Install http-agent
as a global module in your system using apm.
or
Specify the http-agent
module as a dependency in your project and import it to your namespace using apm.
All contributions are welcome! Read our Contribution Guidelines, fork this repo, and create a pull request.
You can install the developer version of ABAP HTTP Agent using abapGit either by creating a new online repository for https://github.com/abapPM/ABAP-HTTP-Agent
.
Recommended SAP package: $HTTP-AGENT
Made with ❤ in Canada
Copyright 2025 apm.to Inc. https://apm.to