08-24-2018 12:07 PM
Hello,
how can I call an URL from SAP (with report or fuba) with automatic login?
Example: I call the URL https://appdemo.docusign.com/home
then I have login in Internet Explorer.
Via http_client I can set the Login E-Mail and Password.
I get the response everything is ok. But how can I call the url now.
my Coding:
DATA: lo_http_client TYPE REF TO if_http_client,
lv_service TYPE string,
lv_result TYPE string,
lo_ixml TYPE REF TO if_ixml,
lo_streamfactory TYPE REF TO if_ixml_stream_factory,
lo_istream TYPE REF TO if_ixml_istream,
lo_document TYPE REF TO if_ixml_document,
lo_parser TYPE REF TO if_ixml_parser,
lo_weather_element TYPE REF TO if_ixml_element,
lo_weather_nodes TYPE REF TO if_ixml_node_list,
lo_curr_node TYPE REF TO if_ixml_node,
lv_value TYPE string,
lv_node_length TYPE i,
lv_node_index TYPE i,
lv_node_name TYPE string,
lv_node_value TYPE string.
lv_service = 'https://demo.docusign.net/xxxxxx'.
cl_http_client=>create_by_url(
EXPORTING
url = lv_service
IMPORTING
client = lo_http_client
EXCEPTIONS
argument_not_found = 1
plugin_not_active = 2
internal_error = 3
OTHERS = 4 ).
lo_http_client->request->set_method( 'GET' ).
CALL METHOD lo_http_client->request->set_header_field
EXPORTING
name = 'X-DocuSign-Authentication'
value = '<DocuSignCredentials><Username>xxxxxxxxx</Username><Password>xxxxxxxxx</Password><IntegratorKey>xxxxxx</IntegratorKey></DocuSignCredentials>'.
CALL METHOD lo_http_client->request->set_header_field
EXPORTING
name = 'Accept'
value = 'application/json'.
lo_http_client->send(
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2 ).
lo_http_client->receive(
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3 ).
CLEAR lv_result .
DATA: lv_result_x TYPE xstring.
lv_result = lo_http_client->response->get_cdata( ).
lv_result_x = lo_http_client->response->get_data( ).
DATA: lv_ret_code TYPE i,
lv_err_string TYPE string.
lo_http_client->response->get_status(
IMPORTING
code = lv_ret_code
reason = lv_err_string ). "here lv_err_string = OK
08-25-2018 10:03 PM
Hi
Just set the API Url and send the request - the authentication info is either stored in a cookie (will be sent automatically) or you need to set some header field or GET/POST parameter
lo_http_client->refresh_request( EXCEPTIONS http_action_failed = 1
OTHERS = 2 ).
IF sy-subrc <> 0.
"Error Handling
ENDIF.
cl_http_utility=>set_request_uri( request = lo_http_client->request uri = 'API URL' ).
lo_http_client->send( EXCEPTIONS http_communication_failure = 1
http_invalid_state = 2
OTHERS = 3 ).
IF sy-subrc <> 0.
"Error Handling
ENDIF.
regards
Domi
08-27-2018 4:37 PM
How can I get here the url from response and call it with CALL_BROWSER?
09-06-2018 6:05 PM
Hi
This is part of the API - I know some of them, but definitely not all!
Just get the AUTH token and provide it with the next call (e.g. with method CL_GUI_HTML_VIEWER->SHOW_URL_IN_BROWSER)
And please: RTFM
regards
Domi
08-26-2018 8:57 AM
Create a destination in SM59, with the credentials for login. Then use cl_http_client=>create_by_destination to get your client.
See here for details https://blogs.sap.com/2014/11/09/calling-an-external-restful-service-from-abap-http-method-get/
08-28-2018 11:44 AM
08-28-2018 12:45 PM
Sorry. Thought you were consuming a webservice. Didn't realise you actually want a browser session.
08-27-2018 10:23 AM
Please post a new question (CALL_BROWSER automatic login via HTTPS), as it's different from your original question (automatic login via CL_HTTP_CLIENT)