{"id":15148472,"url":"https://github.com/furkancosgun/abap-http-client","last_synced_at":"2025-07-16T13:05:28.637Z","repository":{"id":253071016,"uuid":"842350880","full_name":"furkancosgun/ABAP-HTTP-CLIENT","owner":"furkancosgun","description":"ABAP HTTP CLIENT is an ABAP-based project that provides a comprehensive and flexible HTTP client class for performing various types of HTTP operations. This project is designed to simplify and standardize HTTP communication within SAP systems.","archived":false,"fork":false,"pushed_at":"2025-02-26T13:36:35.000Z","size":57,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-07T02:47:25.728Z","etag":null,"topics":["abap","abap-oo","abapgi","client","http","http-client","oop"],"latest_commit_sha":null,"homepage":"","language":"ABAP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/furkancosgun.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-14T07:09:35.000Z","updated_at":"2025-02-26T13:36:38.000Z","dependencies_parsed_at":"2024-09-12T01:22:41.307Z","dependency_job_id":"96ec6a4f-1ea6-4577-816e-73ab78029c66","html_url":"https://github.com/furkancosgun/ABAP-HTTP-CLIENT","commit_stats":null,"previous_names":["furkancosgun/zabap_http_client","furkancosgun/abap_http_client","furkancosgun/abap-http-client"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/furkancosgun%2FABAP-HTTP-CLIENT","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/furkancosgun%2FABAP-HTTP-CLIENT/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/furkancosgun%2FABAP-HTTP-CLIENT/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/furkancosgun%2FABAP-HTTP-CLIENT/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/furkancosgun","download_url":"https://codeload.github.com/furkancosgun/ABAP-HTTP-CLIENT/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247584061,"owners_count":20962071,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["abap","abap-oo","abapgi","client","http","http-client","oop"],"created_at":"2024-09-26T13:03:59.367Z","updated_at":"2025-04-07T02:47:31.054Z","avatar_url":"https://github.com/furkancosgun.png","language":"ABAP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ABAP HTTP CLIENT\n\nThis project demonstrates the use of a custom HTTP client class for handling HTTP requests and responses in ABAP. The provided examples cover various HTTP operations including GET, POST, PUT, DELETE requests, and multipart file uploads.\n\n## License\nThis project is licensed under the [MIT License](LICENSE). See the LICENSE file for details.\n\n## Contents\n- [GET Request Example](#get-request-example)\n- [POST Request with JSON Data](#post-request-with-json-data)\n- [PUT Request with Form Data](#put-request-with-form-data)\n- [DELETE Request Example](#delete-request-example)\n- [Multipart File Upload](#multipart-file-upload)\n- [POST Request with Authorization Header](#post-request-with-authorization-header)\n- [HTTP Client Handler Class](#http-client-handler-class)\n\n### GET Request Example\nExample of making a GET request to fetch data from a URL:\n```abap\nSTART-OF-SELECTION.\n  DATA(lo_client) = zcl_abap_http_client=\u003ecreate(\n    baseurl = 'https://api.example.com'\n    path = '/data'\n  ).\n\n  lo_client-\u003eget(\n    EXPORTING\n      query_parameters = VALUE #( ( name = 'param1' value = 'value1' ) ) \"?param1=value1\n  )-\u003esend(\n    IMPORTING\n      eo_response = DATA(lo_response)\n    EXCEPTIONS\n      http_communication_failure = 1\n      OTHERS = 2\n  ).\n  IF sy-subrc \u003c\u003e 0.\n    WRITE: / 'GET request failed'.\n    RETURN.\n  ENDIF.\n\n  cl_demo_output=\u003edisplay_json( json = lo_response-\u003eget_cdata( ) ).\n```\n\n### POST Request with JSON Data\nExample of making a POST request and sending data in JSON format:\n```abap\nSTART-OF-SELECTION.\n  DATA(lo_client) = zcl_abap_http_client=\u003ecreate(\n    baseurl = 'https://api.example.com'\n    path = '/submit'\n  ).\n\n  lo_client-\u003epost(\n    EXPORTING\n      body = '{ \"key\": \"value\" }'\n      content_type = zcl_abap_http_client=\u003econtent_types-json\n  )-\u003esend(\n    IMPORTING\n      eo_response = DATA(lo_response)\n    EXCEPTIONS\n      http_communication_failure = 1\n      OTHERS = 2\n  ).\n  IF sy-subrc \u003c\u003e 0.\n    WRITE: / 'POST request failed'.\n    RETURN.\n  ENDIF.\n\n  cl_demo_output=\u003edisplay_json( json = lo_response-\u003eget_cdata( ) ).\n```\n\n### PUT Request with Form Data\nExample of making a PUT request and sending form data:\n```abap\nSTART-OF-SELECTION.\n  DATA(lo_client) = zcl_abap_http_client=\u003ecreate(\n    baseurl = 'https://api.example.com'\n    path = '/update'\n  ).\n\n  lo_client-\u003eput(\n    EXPORTING\n      form_fields = VALUE #( ( name = 'key1' value = 'value1' ) ( name = 'key2' value = 'value2' ) )\n      content_type = zcl_abap_http_client=\u003econtent_types-form_urlencoded\n  )-\u003esend(\n    IMPORTING\n      eo_response = DATA(lo_response)\n    EXCEPTIONS\n      http_communication_failure = 1\n      OTHERS = 2\n  ).\n  IF sy-subrc \u003c\u003e 0.\n    WRITE: / 'PUT request failed'.\n    RETURN.\n  ENDIF.\n\n  cl_demo_output=\u003edisplay_json( json = lo_response-\u003eget_cdata( ) ).\n```\n\n### DELETE Request Example\nExample of making a DELETE request to remove a resource:\n```abap\nSTART-OF-SELECTION.\n  DATA(lo_client) = zcl_abap_http_client=\u003ecreate(\n    baseurl = 'https://api.example.com'\n    path = '/delete'\n  ).\n\n  lo_client-\u003edelete(\n    EXPORTING\n      query_parameters = VALUE #( ( name = 'id' value = '123' ) ) \"?id=123\n  )-\u003esend(\n    IMPORTING\n      eo_response = DATA(lo_response)\n    EXCEPTIONS\n      http_communication_failure = 1\n      OTHERS = 2\n  ).\n  IF sy-subrc \u003c\u003e 0.\n    WRITE: / 'DELETE request failed'.\n    RETURN.\n  ENDIF.\n\n  cl_demo_output=\u003edisplay_json( json = lo_response-\u003eget_cdata( ) ).\n```\n\n### Multipart File Upload\nExample of making a POST request to upload a file using multipart data:\n```abap\nSTART-OF-SELECTION.\n  DATA(lo_client) = zcl_abap_http_client=\u003ecreate(\n    baseurl = 'https://api.example.com'\n    path = '/upload'\n  ).\n\n  DATA(lx_file_data) = zcl_example_reader=\u003eread_file( path = 'path/to/your/file.txt' ). \" type xstring\n  \n  lo_client-\u003epost(\n    EXPORTING\n      multipart_files = VALUE #( ( name = 'file' filename = 'file.txt' content_type = 'text/plain' data = lx_file_data ) )\n      content_type = zcl_abap_http_client=\u003econtent_types-formdata\n  )-\u003esend(\n    IMPORTING\n      eo_response = DATA(lo_response)\n    EXCEPTIONS\n      http_communication_failure = 1\n      OTHERS = 2\n  ).\n  IF sy-subrc \u003c\u003e 0.\n    WRITE: / 'POST request failed'.\n    RETURN.\n  ENDIF.\n\n  cl_demo_output=\u003edisplay_json( json = lo_response-\u003eget_cdata( ) ).\n```\n\n### POST Request with Authorization Header\nExample of making a POST request with authorization by including an authorization header:\n```abap\nSTART-OF-SELECTION.\n  DATA(lo_client) = zcl_abap_http_client=\u003ecreate(\n    baseurl = 'https://example.com'\n    path = '/data'\n  ).\n\n  \" Prepare authorization header\n  DATA(lv_username_and_password) = |{ 'your_username' }:{ 'your_password' }|.\n\n  DATA(lv_basic_auth) = |Basic { cl_http_utility=\u003eencode_base64( unencoded = lv_username_and_password ) }|.\n\n  lo_client-\u003epost(\n    EXPORTING\n      body = '{ \"data\":\"123\" }'\n      header_fields = VALUE #( ( name = 'Authorization' value = lv_basic_auth ) )\n  )-\u003esend(\n    IMPORTING\n      eo_response = DATA(lo_response)\n    EXCEPTIONS\n      http_communication_failure = 1\n      OTHERS = 2\n  ).\n  IF sy-subrc \u003c\u003e 0.\n    WRITE: / 'POST request failed'.\n    RETURN.\n  ENDIF.\n\n  cl_demo_output=\u003edisplay_json( json = lo_response-\u003eget_cdata( ) ).\n```\n\n\n### HTTP Client Handler Class\nExample of defining a class to handle HTTP client events:\n```abap\nCLASS zcl_http_client_handler DEFINITION.\n  PUBLIC SECTION.\n    METHODS:\n      \" Event handler for before request is sent\n      on_before_request_sent\n        FOR EVENT before_request_sent OF zcl_abap_http_client\n        IMPORTING sender request,\n\n      \" Event handler for after request is sent\n      on_after_request_sent\n        FOR EVENT after_request_sent OF zcl_abap_http_client\n        IMPORTING sender request,\n\n      \" Event handler for when the response is received\n      on_response_received\n        FOR EVENT response_received OF zcl_abap_http_client\n        IMPORTING sender client.\nENDCLASS.\n\nCLASS zcl_http_client_handler IMPLEMENTATION.\n  METHOD on_before_request_sent.\n    \" Actions before request is sent (e.g., logging)\n    WRITE: / 'Request is about to be sent'.\n  ENDMETHOD.\n\n  METHOD on_after_request_sent.\n    \" Actions after request is sent (e.g., logging)\n    WRITE: / 'Request has been sent'.\n  ENDMETHOD.\n\n  METHOD on_response_received.\n    \" Actions when response is received (e.g., processing response)\n    WRITE: / 'Response received'.\n  ENDMETHOD.\nENDCLASS.\n\nSTART-OF-SELECTION.\n  \" Create a handler instance\n  DATA(lo_handler) = NEW zcl_http_client_handler( ).\n  \n  \" Create an HTTP client instance\n  DATA(lo_client) = zcl_abap_http_client=\u003ecreate(\n    baseurl = 'https://example.com'\n    path = '/data'\n  ).\n\n  \" Set event handlers\n  SET HANDLER lo_handler-\u003eon_before_request_sent FOR lo_client.\n  SET HANDLER lo_handler-\u003eon_after_request_sent FOR lo_client.\n  SET HANDLER lo_handler-\u003eon_response_received FOR lo_client.\n\n  \" Perform a GET request and send it\n  lo_client-\u003eget(\n  )-\u003esend(\n    IMPORTING\n      eo_response = DATA(lo_response)\n    EXCEPTIONS\n      http_communication_failure = 1\n      OTHERS = 2\n  ).\n  IF sy-subrc \u003c\u003e 0.\n    WRITE: / 'Request failed'.\n    RETURN.\n  ENDIF.\n\n  cl_demo_output=\u003edisplay_json( json = lo_response-\u003eget_cdata( ) ).\n```\n\nFeel free to adjust any details according to your specific needs or preferences.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffurkancosgun%2Fabap-http-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffurkancosgun%2Fabap-http-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffurkancosgun%2Fabap-http-client/lists"}