Get Data from https://smard.api.bund.dev/ not working (complete ABAP-Code is in post)

Good morning,

I have to code some ABAP to receive data from https://smard.api.bund.dev/

For my first attemped I used the URL “https://smard.api.proxy.bund.dev/app/chart_data/1223/DE/index_hour.json”

When I use this URL in the browser I see/get mariomueller68_1-1741669507050.png

 

 

I created a SM59 connection: mariomueller68_0-1741669374189.png

 

 

My code is:

 

DATA: lo_http_client TYPE REF TO if_http_client,
lv_url TYPE string.

cl_http_client=>create_by_destination(
EXPORTING
destination = ‘BUNDESNETZAGENTURSTROMMARKTDATEN’
IMPORTING
client = lo_http_client ” HTTP Client object
EXCEPTIONS
argument_not_found = 1
destination_not_found = 2
destination_no_authority = 3
plugin_not_active = 4
internal_error = 5
OTHERS = 6 ).

lo_http_client->request->set_method( if_http_request=>co_request_method_post ).
lo_http_client->request->set_version( if_http_request=>co_protocol_version_1_1 ).
lv_url =
‘/app/chart_data/1223/DE/index_hour.json’.

CALL METHOD cl_http_utility=>set_request_uri
EXPORTING
request = lo_http_client->request
uri = lv_url.

lo_http_client->request->set_content_type( ‘application/json’ ).
CALL METHOD lo_http_client->send “sending request to api
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2.

CALL METHOD lo_http_client->receive “receiving response from api
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3.

DATA:
* http_status TYPE string,
reason TYPE string,
response TYPE string.

CALL METHOD lo_http_client->response->get_status
IMPORTING
code = data(http_status)
reason = reason.

response = lo_http_client->response->get_cdata( ).
* cl_demo_output=>display_json( json = json_response ).
cl_demo_output=>display_text( text = response ).

 

But my ABAP Code displays only: mariomueller68_2-1741669569203.png

 

What I am doing wrong

 

 

 

 
 

 

 

Scroll to Top