in src/zadf/zadf_graph/zcl_adf_service_graph.clas.abap [0:0]
METHOD zif_adf_service_graph~get_users.
TYPES: BEGIN OF response,
value TYPE zif_adf_service_graph~users,
END OF response.
DATA: lo_response TYPE REF TO if_rest_entity,
lo_request TYPE REF TO if_rest_entity,
lv_path_prefix TYPE string,
lv_host_s TYPE string,
ls_response TYPE response.
IF go_rest_api IS BOUND.
lv_path_prefix = '/users'.
IF NOT lv_path_prefix IS INITIAL.
go_rest_api->zif_rest_framework~set_uri( lv_path_prefix ).
ENDIF.
lv_host_s = gv_host.
**Add header attributes in REST call.
add_request_header( iv_name = 'Content-Type' iv_value = 'application/json; charset=utf-8' ).
add_request_header( iv_name = 'Host' iv_value = lv_host_s ).
add_request_header( iv_name = 'Authorization' iv_value = |Bearer | && iv_aad_token ).
**Rest API call to get response from Azure Destination
lo_response = go_rest_api->zif_rest_framework~execute(
io_entity = lo_request
async = gv_asynchronous
is_retry = gv_is_try
).
ev_http_status = go_rest_api->get_status( ).
IF lo_response IS BOUND.
DATA(response) = lo_response->get_string_data( ).
IF ev_http_status = 400.
RAISE EXCEPTION TYPE zcx_adf_service_graph
EXPORTING
textid = zcx_adf_service_graph=>general_exception
error_response = response.
ELSE.
/ui2/cl_json=>deserialize(
EXPORTING
json = response " Data to serialize
" pretty_name = abap_true " Pretty Print property names
CHANGING
data = ls_response
).
rt_users = ls_response-value.
ENDIF.
ELSE.
RAISE EXCEPTION TYPE zcx_adf_service
EXPORTING
textid = zcx_adf_service=>restapi_response_not_found
interface_id = gv_interface_id.
ENDIF.
go_rest_api->close( ).
ENDIF.