on 02-09-2024 10:43 PM
Hi Experts,
I want to create new record to custom CBO from SAP Marketing cloud BAdi
I have tried following this URL but I am getting an error " 403 Unified Connectivity: Forbidden"
Communication Scenario
Communication Arrangement
Communication System
In the below code while executing line DATA(response3) = lo_client->send( request2 ).
I am getting error " 403 Unified Connectivity: Forbidden"
I am not sure where I have to maintain HTTP user and password , it is already maintained in the communication arragment.
Please could you help me.
Thanks.
" Step:1-* Check if communication arrangement is available and active
TRY.
CHECK cl_ble_http_client=>is_service_available(
communication_scenario = 'YY1_INT_HTTP'
outbound_service = 'YY1_INT_HTTP_REST'
) = abap_true.
CATCH cx_ble_http_exception INTO DATA(lx_error_http_service).
"for All errors
lv_MSGV1 = lx_error_http_service->status_code.
lv_MSGV2 = lx_error_http_service->status_description.
CONCATENATE lv_MSGV1 lv_MSGV2 INTO Data(lv_return_message).
cl_ble_trace_writer=>write_info_message( lv_return_message ).
ENDTRY.
lv_return_message = 'HTTP Service Check Sucessfull'.
cl_ble_trace_writer=>write_info_message( lv_return_message ).
TRY.
" Step:2-* Create HTTP client for the Outbound Service
DATA(lo_client) = cl_ble_http_client=>create(
communication_scenario = 'YY1_INT_HTTP'
outbound_service = 'YY1_INT_HTTP_REST'
).
CATCH cx_ble_http_exception INTO DATA(lx_error_OS_creation).
"for All errors
lv_MSGV1 = lx_error_OS_creation->status_code.
lv_MSGV2 = lx_error_OS_creation->status_description.
CONCATENATE lv_MSGV1 lv_MSGV2 INTO lv_return_message.
cl_ble_trace_writer=>write_info_message( lv_return_message ).
ENDTRY.
lv_return_message = 'Create HTTP request is successful'.
cl_ble_trace_writer=>write_info_message( lv_return_message ).
" Step:3-* Create HTTP request and Fetch CSRF toker
TRY.
DATA(request) = cl_ble_http_request=>create( ).
DATA lv_s2p TYPE string VALUE '/YY1_PRODUCT_MASTER_HELPER_CDS/YY1_PRODUCT_MASTER_HELPER?$top=1 '.
request->set_header_parameter( EXPORTING name = 'X-CSRF-TOKEN' value = 'FETCH' ).
request->set_header_parameter( EXPORTING name = 'Accept' value = 'application/json' ).
request->set_header_parameter( EXPORTING name = 'Content_Type' value = 'application/json' ).
request->set_method( 'GET' )->set_resource_extension( lv_s2p ).
cl_ble_trace_writer=>write_info_message( 'Before reading CSEF token' ).
DATA(response1) = lo_client->send( request ).
DATA(lv_csrf1) = response1->get_header_parameter( 'x-csrf-token' ).
cl_ble_trace_writer=>write_info_message( 'After reading CSEF token' ).
CATCH cx_ble_http_exception INTO DATA(lx_error_fetch_csrf).
"for All errors
lv_MSGV1 = lx_error_fetch_csrf->status_code.
lv_MSGV2 = lx_error_fetch_csrf->status_description.
CONCATENATE lv_MSGV1 lv_MSGV2 INTO lv_return_message.
cl_ble_trace_writer=>write_info_message( lv_return_message ).
ENDTRY.
lv_return_message = 'Fetch CSRF toker is successful'.
cl_ble_trace_writer=>write_info_message( lv_return_message ).
" Step:4- * Concatenate json format body
TRY.
IF lv_csrf1 IS NOT INITIAL.
cl_ble_trace_writer=>write_info_message( lv_csrf1 ).
DATA ls_double_quot TYPE string VALUE '"'.
DATA ls_single_comm TYPE string VALUE ','.
DATA ls_double_coll TYPE string VALUE ':'.
DATA ls_open_brack TYPE string VALUE '{'.
DATA ls_clos_brack TYPE string VALUE '}'.
DATA ls_single_dot TYPE string VALUE '.'.
DATA ls_product_id TYPE string VALUE '"ProductID"'.
DATA ls_Status TYPE string VALUE '"Status"'.
DATA Remarks TYPE string VALUE '"SAP_Description"'.
data(lst_status) = 'Not Existing'.
data(lst_remarks) = 'from Revise Interaction Before Creation BAdi'.
* { "PRODUCT_ID": "98765", "STATUS": "Not Existing", "SAP_Description": "from Revise Interaction Before Creation BAdi" }.
CONCATENATE ls_open_brack ls_product_id ls_double_coll ls_double_quot lv_product_id ls_double_quot ls_single_comm INTO Data(lv3_product_id).
CONCATENATE ls_Status ls_double_coll ls_double_quot lst_status ls_double_quot ls_single_comm INTO Data(lv3_status).
CONCATENATE Remarks ls_double_coll ls_double_quot lst_remarks ls_double_quot ls_clos_brack INTO Data(lv3_remarks).
CONCATENATE lv3_product_id lv3_status lv3_remarks INTO Data(lv_payloadp).
cl_ble_trace_writer=>write_info_message( lv_payloadp ).
" Step:6- * Calling service
DATA(request2) = cl_ble_http_request=>create( ).
DATA lv_s3p TYPE string VALUE 'YY1_PRODUCT_MASTER_HELPER_CDS/YY1_PRODUCT_MASTER_HELPER'.
request2->set_header_parameter( EXPORTING name = 'x-csrf-token' value = lv_csrf1 ).
request2->set_header_parameter( EXPORTING name = 'Accept' value = 'application/json' ).
request2->set_header_parameter( EXPORTING name = 'Content_Type' value = 'application/json' ).
request2->set_method( 'POST' )->set_resource_extension( lv_s3p ).
request2->set_body( lv_payloadp ).
cl_ble_trace_writer=>write_info_message( 'Before sending Payload' ).
cl_ble_trace_writer=>write_info_message( lv_payloadp ).
DATA(response3) = lo_client->send( request2 ).
DATA(lv_xml) = response3->get_body( ).
cl_ble_trace_writer=>write_info_message( lv_xml ).
lv_return_message = 'Final Service Call is successful'.
cl_ble_trace_writer=>write_info_message( lv_return_message ).
ENDIF ."IF lv_csrf1 IS NOT INITIAL.
CATCH cx_ble_http_exception INTO DATA(lx_error_Call_Service).
"for All errors
lv_MSGV1 = lx_error_Call_Service->status_code.
lv_MSGV2 = lx_error_Call_Service->status_description.
CONCATENATE lv_MSGV1 lv_MSGV2 INTO lv_return_message.
cl_ble_trace_writer=>write_info_message( lv_return_message ).
RETURN.
ENDTRY.
Hello,
Did you solve it?
I have followed the same steps as you, but i'm getting:
Exception CX_BLE_HTTP_EXCEPTION occurred in CL_BLE_HTTP_CLIENT
Outbound call failed with status code 403, reason: Unified Connectivity: Forbidden. [BLE_RUNTIME_SUPPORT(010)]
Can you help me?
Regards,
Ines Martins
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
4 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.