Code: Alles auswählen.
TRY.
TYPES: BEGIN OF ty_test,
pernnr TYPE p2001-pernr,
awart TYPe p2001-awart,
END OF ty_test.
DATA: lo_client TYPE REF TO if_http_client,
lo_request TYPE REF TO if_http_request,
lv_rc TYPE sy-subrc,
lv_http_rc TYPE sy-subrc,
lv_xml_xstring TYPE xstring,
lv_xml_string TYPE string,
lv_url TYPE string VALUE 'X'.
DATA: lv_data TYPE ty_test,
gs_json TYPE string.
CALL METHOD cl_http_client=>create_by_url
EXPORTING
url = lv_url
proxy_host = 'X'
proxy_service = '8080'
* ssl_id =
* sap_username =
* sap_client =
IMPORTING
client = lo_client
EXCEPTIONS
argument_not_found = 1
plugin_not_active = 2
internal_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
CALL METHOD lo_client->authenticate(
EXPORTING
proxy_authentication = 'X'
client = '200'
username = X
password = X
language = X
).
*
*DATA: http_dest TYPE rfcdest VALUE 'ZTEST_HTTP'.
*
* cl_http_client=>create_by_destination( EXPORTING
* destination = http_dest IMPORTING client = lo_client ).
*
* CALL METHOD lo_client->request->set_method(
* if_http_request=>co_request_method_get ).
CALL METHOD lo_client->send
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
http_invalid_timeout = 4
OTHERS = 5.
IF sy-subrc <> 0.
RAISE connection_error.
ENDIF.
CALL METHOD lo_client->receive
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
OTHERS = 4.
IF lv_rc = 0.
**http status code
lo_client->response->get_status( IMPORTING code = lv_http_rc ).
IF lv_http_rc <> 200.
"""KO
ELSE. "status 200 ->>OK
CLEAR: lv_xml_xstring.
lv_xml_xstring = lo_client->response->get_data( ).
ENDIF.
ENDIF.
lo_client->close( ).
DATA(o_conv_r) = cl_abap_conv_in_ce=>create( input = lv_xml_xstring encoding = 'UTF-8' ).
o_conv_r->read( IMPORTING data = lv_xml_string ).
WRITE: / lv_xml_string.
ENDTRY.
Erklär' das mal genauer. Wohin willst du denn die Daten hochladen? In eine Cloud? Ich habe das letztens in eine NextCloud gemacht. Das ist ja am Ende auch nur eine URL. Darum frage ich.ich würde gerne noch Daten per API auf eine URL hochladen.