Skip to Content
author's profile photo Former Member
Former Member

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

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

Add a comment
10|10000 characters needed characters exceeded

Related questions

0 Answers

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.