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) = /apmg/cl_http_agent=>create( ).

" Optionally set headers
agent->global_headers( )->set(
  iv_key = /apmg/if_http_agent=>c_header-accept
  iv_val = /apmg/if_http_agent=>c_content_type-json ).

agent->global_headers( )->set(
  iv_key = /apmg/if_http_agent=>c_header-content_type
  iv_val = /apmg/if_http_agent=>c_content_type-json ).

agent->global_headers( )->set(
  iv_key = /apmg/if_http_agent=>c_header-user_agent
  iv_val = `abap 7.5` ).

Get and set authorization tokens:

DATA(host) = 'api.github.com'.

IF /apmg/cl_http_login_manager=>get( host ) IS NOT INITIAL.
  agent->global_headers( )->set(
    iv_key = /apmg/if_http_agent=>c_header-authorization
    iv_val = /apmg/cl_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  = /apmg/if_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: /APMG/HTTP-AGENT

About

Made with ❤ in Canada

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

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

About

Easy to Use HTTP Agent and Login Manager

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

1 watching

Forks

Sponsor this project

 

Contributors

Languages

Generated from abapPM/Template-for-ABAP