cancel
Showing results for 
Search instead for 
Did you mean: 

Client-side cookies problem with CL_HTTP_CLIENT - cookies disabled by browser

Former Member
0 Kudos

Hello,

I want to receive data from WebSite by https.

The website requires cookies to be enabled.

I wrote following code:

DATA: client TYPE REF TO if_http_client.
DATA: path TYPE string.
DATA: reason TYPE string.
DATA: code TYPE i.
DATA: txt TYPE string.
DATA: cookies TYPE tihttpcki.

CALL METHOD cl_http_client=>create
EXPORTING
host = 'ppuslugi.mf.gov.pl'
* service = '443'
* proxy_host = '83.246.65.140'
* proxy_service = '80'
* scheme = cl_http_client=>schemetype_http
scheme = cl_http_client=>schemetype_https
* ssl_id =
* sap_username =
* sap_client =
IMPORTING
client = 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.

path = '/GetWlbToken'.
client->propertytype_accept_cookie = client->co_enabled. "client->co_prompt.
client->propertytype_accept_compress = client->co_enabled.
client->request->set_version( if_http_request=>co_protocol_version_1_1 ).
client->request->set_method( if_http_request=>co_request_method_get ).
cl_http_utility=>set_request_uri( request = client->request uri = path ).

CALL METHOD client->send
* EXPORTING
* timeout = CO_TIMEOUT_DEFAULT
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
http_invalid_timeout = 4
OTHERS = 5.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.

WRITE sy-subrc.

CALL METHOD client->receive
* EXPORTING
* timeout = CO_TIMEOUT_DEFAULT
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
"http_invalid_timeout = 4
OTHERS = 4.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.

client->response->get_status(
IMPORTING
code = code
reason = reason
EXCEPTIONS
OTHERS = 1
).

WRITE: / 'Response Status Code: ', code, reason.

client->response->get_cookies( CHANGING cookies = cookies ).

client->response->get_cdata(
RECEIVING
data = txt
EXCEPTIONS
OTHERS = 1
).

IF sy-subrc = 0.
WRITE: txt.
ENDIF.

Executing this code I receive cookies and code 200 but web server response is Cookies Disables.

Do you have any idea how to solve it?

Regards,

M

Accepted Solutions (0)

Answers (0)