cancel
Showing results for 
Search instead for 
Did you mean: 

CSRF token retrieval fails when making calls from the SAP BTP ABAP environment to an S/4 HANA on-pre

nishantbansal91
Active Contributor
0 Kudos
170

Hello team,

I am trying to call the S/4 HANA on premise system from ABAP Environment via Destinations.

GET Call is working as expected. 

Below is the code. I am trying to do the post call based on some input parameter

DATA(http_destination) = cl_http_destination_provider=>create_by_cloud_destination(

i_name = CONV #( <fs_sap_systems>-destination_name )

i_authn_mode = if_a4c_cp_service=>service_specific ).

 

lo_http_client = cl_web_http_client_manager=>create_by_http_destination( http_destination ).

lo_client_proxy = /iwbep/cl_cp_factory_remote=>create_v2_remote_proxy(

is_proxy_model_key = VALUE #( repository_id = 'DEFAULT'

proxy_model_id = 'ZSCM_USER_LOCKED'

proxy_model_version = '0001' )

 

io_http_client = lo_http_client

iv_relative_service_root = '/sap/opu/odata/sap/ZS_USER_LOCKS_SRV1111/' ).

 

" Prepare business data

ls_business_data = VALUE #( uname = is_user_locked_st-uname ).

 

" Navigate to the resource and create a request for the create operation

lo_request = lo_client_proxy->create_resource_for_entity_set( 'USER_LIST_LOCK_SET' )->create_request_for_create( ).

 

" Set the business data for the created entity

lo_request->set_business_data( ls_business_data ).

 

lo_response = lo_request->execute( ).

After executing the statement, I encounter a CSRF token failed exception. Is there a need to upload any certificate on the S/4 HANA side?

View Entire Topic
junwu
Active Contributor
0 Kudos

https://community.sap.com/t5/technology-blogs-by-sap/how-to-execute-actions-or-function-imports-in-r...

there are some code to get csrf token and send for post call.

check if you can incorporate the code .

nishantbansal91
Active Contributor
0 Kudos
Hello Junwu, I am able to fetch the CSRF token via this code. Thank you for your help
junwu
Active Contributor
0 Kudos
good to know it works, please close the topic if your question is answered.