Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- REPORT z_sva_test_fedorov.
- DATA: lv_body TYPE string,
- lv_body2 TYPE string,
- lv_body_date TYPE string,
- lv_body_rate TYPE string VALUE '3'.
- DATA: lo_client TYPE REF TO if_http_client,
- lo_rest_client TYPE REF TO cl_rest_http_client.
- *
- *
- ** call_WS_data_currency
- DATA(lv_url) = |https://integration.ekvio.ru/v3/users/sync|.
- cl_http_client=>create_by_url(
- EXPORTING
- url = lv_url
- ssl_id = 'ANONYM'
- IMPORTING
- client = lo_client
- EXCEPTIONS
- argument_not_found = 1
- internal_error = 2
- plugin_not_active = 3 ).
- IF sy-subrc IS NOT INITIAL.
- lo_client->get_last_error(
- IMPORTING
- message = DATA(lv_error_text) ).
- ENDIF.
- *
- *
- CREATE OBJECT lo_rest_client " создали клиента
- EXPORTING
- io_http_client = lo_client.
- *
- lo_client->request->set_version( if_http_request=>co_protocol_version_1_1 ). " параметры
- ******* rest body
- DATA(lo_request) = lo_rest_client->if_rest_client~create_request_entity( ).
- lo_request->set_content_type( iv_media_type = if_rest_media_type=>gc_appl_json ).
- lo_request->set_header_field(
- EXPORTING
- iv_name = 'Authorization'
- iv_value = |Bearer 0WvhXXMx4ePpAFN46aHjReSLGsu5HQCF| ).
- lv_body = '{"data": [ { "login": "petrov_iv", "password": "password123456", "first_name": "Ivan", "last_name": "Ivan", "email": "[email protected]", "phone": "79275222222", "chief_email": "[email protected]",' &&
- '"status": "active", "invited": true } ], "partial_sync": true, "chief_sync": true, "notify_users": true, "with_whitelist": true }'.
- lo_request->set_string_data( lv_body ).
- ******* post
- TRY.
- lo_rest_client->if_rest_resource~post( io_entity = lo_request ).."( lo_request ).
- DATA(lo_response) = lo_rest_client->if_rest_client~get_response_entity( ).
- DATA(lv_http_status) = lo_response->get_header_field( '~status_code' ).
- DATA(lv_test) = lo_response->get_string_data( ).
- CATCH cx_rest_client_exception INTO DATA(lo_exception).
- DATA(lv_msg) = `HTTP POST failed: ` && lo_exception->get_text( ).
- ENDTRY.
- IF lo_rest_client IS BOUND .
- lo_rest_client->if_rest_client~close( ).
- ENDIF.
Add Comment
Please, Sign In to add comment