Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sbcgua/abap-http-agent
AHA - abap http agent, convenience wrapper over cl_http_client
https://github.com/sbcgua/abap-http-agent
abap hacktoberfest
Last synced: about 2 months ago
JSON representation
AHA - abap http agent, convenience wrapper over cl_http_client
- Host: GitHub
- URL: https://github.com/sbcgua/abap-http-agent
- Owner: sbcgua
- License: mit
- Created: 2020-07-05T09:52:10.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-09-21T19:17:11.000Z (over 2 years ago)
- Last Synced: 2024-10-04T20:31:14.185Z (3 months ago)
- Topics: abap, hacktoberfest
- Language: ABAP
- Homepage:
- Size: 41 KB
- Stars: 7
- Watchers: 3
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- abap-florilegium - abap-http-agent - abap http agent, convenience wrapper over cl_http_client | `http` (Categories / 🐝 API & Services)
README
![abaplint](https://github.com/sbcgua/abap-http-agent/workflows/abaplint/badge.svg)
![abap package version](https://img.shields.io/endpoint?url=https://shield.abap.space/version-shield-json/github/sbcgua/abap-http-agent/src/zif_aha_http_agent.intf.abap)# AHA - abap http agent
Convenience wrapper over cl_http_client
WIP
TODO:
- url destination
- integrate with json ?
- proxy ?
- resumable password exception ?## Example
### GET
```abap
data lt_query type zif_aha_http_agent=>tty_key_value.
data lt_header type zif_aha_http_agent=>tty_key_value.
field-symbols like line of lt_query.append initial line to lt_query assigning .
-key = 'id'.
-val = '1234'.
append initial line to lt_header assigning .
-key = 'content-type'.
-val = 'application/json'.data lo_agent type ref to zif_aha_http_agent.
data li_resp type ref to zif_aha_http_response.
lo_agent = zcl_aha_http_agent=>create( iv_destination = 'MYDESTINATION' ).li_resp = lo_agent->request(
iv_uri = 'service/1'
it_query = lt_query
it_headers = lt_header ).if li_resp->is_ok( ) = abap_true.
do_my_processing( li_resp->data( ) ).
else.
report_error( li_resp->error( ) ).
endif.
```headers and query integrates well with [abap-string-map](https://github.com/sbcgua/abap-string-map)
```abap
data lo_query type ref to zcl_abap_string_map.
create object lo_query.lo_query->set( iv_key = 'id' iv_val = '1234' ).
...
li_resp = lo_agent->request(
iv_uri = 'service/1'
it_query = lo_query->mt_entries ).
```### POST
```abap
data lo_agent type ref to zif_aha_http_agent.
lo_agent = zcl_aha_http_agent=>create( iv_destination = 'MYDESTINATION' ).data lv_payload type xstring value '102030'.
lo_agent->request(
iv_method = zif_aha_http_response=>c_methods-post
iv_uri = 'service/1'
iv_payload = lv_payload ).
```### Multipart payload
```abap
data lt_multipart type zif_aha_http_agent=>tt_multipart.
field-symbols like line of lt_multipart.
append initial line to lt_multipart assigning .
-content_type = 'application/pdf'.
-data = 'some binary data here...'.
-filename = 'myfile.pdf'.
-name = 'myfile'.lo_cut->request(
iv_method = zif_aha_http_response=>c_methods-post
iv_uri = 'service/1'
iv_payload = lt_multipart ).
```