Hello,
I have an XML file and I need to save it in a HTTP patch.
The transformation code it's working and I created an HTTP connection(SM59) that is working as well. I'm never did that before but I guess that I'm open the connection on my ABAP code, since it ask for user and password to login, but I have no idea how to save something in there.
Follow the code:
data: client type ref to if_http_client.
data: request type ref to if_http_request.
cl_http_client=>create_by_destination(
exporting destination = http_dest
importing client = client ).
call method client->request->set_method(
if_http_request=>co_request_method_get ).
* set protocol version
client->request->set_version(
if_http_request=>co_protocol_version_1_0 ).
* content type
call method client->request->if_http_entity~set_content_type
exporting
content_type = 'multipart/form-data'.
*** Send HTTP request
call method 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.
*** Get GTTP response
call method client->receive
exceptions
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
others = 4.
if rc = 0.
*** Read HTTP RETURN CODE
client->response->get_status( importing code = http_rc ).
if http_rc <> 200.
"""KO
else. "status 200 ->>OK
clear: xml_xstring.
xml_xstring = client->response->get_data( ).
endif.
endif.
* VERY IMPORTANT: close your connection
client->close( ).
call function 'SRTUTIL_HELPER_XML_SHOW'
exporting
xdoc = xml_xstring
html = abap_false.
Thanks,
Andréa