Skip to content

abapPM/ABAP-HTTP-Agent

Repository files navigation

Version

License Contributor Covenant REUSE Status

HTTP Agent

Easy to use HTTP agent and login manager with request/response handling.

NO WARRANTIES, MIT License

Usage

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.

Prerequisites

SAP Basis 7.50 or higher

Installation

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.

Contributions

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

About

Made with ❤ in Canada

Copyright 2025 apm.to Inc. https://apm.to

Follow @marcf.be on Blueksy and @marcfbe or LinkedIn

About

Easy to Use HTTP Agent and Login Manager

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Languages