cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

URL encoding inside BAdI - SAP marketing cloud

0 Likes
1,573

Hi experts,

I am consuming a public API(REST) inside a BAdI implementation for SAP Marketing cloud. Before I send the API request I need to encode the URL parameter to get the right response. In the BAdI implementation I can use only ABAP for key users which has specific limitations and I can't use the standard class cl_http_utility for this purpose. Is there an another way how to achieve it?

the coding looks like:

" Create HTTP client to access the outbound service
                DATA(lo_client) = cl_ble_http_client=>create(
                    communication_scenario = 'YY1_API_GPS_COORD_MAPQUEST'
                    outbound_service       = 'YY1_MAPQUESTAPI_REST'
                    ).

                " Creation of the service request
                DATA(lo_request) = cl_ble_http_request=>create(
                " method that is used for the service call
                )->set_method(
                    if_ble_http_request=>co_method-get
                ).
...
" URL lo_request looks like =>
https://open.mapquestapi.com/geocoding/v1/address?key=XXXXX&location=Vyskočilova 15,Praha,CZ&thumbMaps=false
...
                " Send a request and receive a response.
                DATA(lo_response) = lo_client->send( lo_request ).

                " Get the body of the response.
    	        DATA(ls_body) = lo_response->get_body( ).

If I send the same GET request via my browser or via the postman app I will get the right response:

If I check the response of the API in my BAdI implementation I am getting the wrong response because the 'č' character in the name of street is missing. The URL encoding would solve this problem, but I don't know how to achieve it without the possibility to use cl_http_utility class. Any idea?

Thank you in advance.

Jaro.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member

Hi,

I solved this issue using escape() function. It works fine for me.

Regards

Jaro

former_member226
Employee
Employee
0 Likes

Hi,

Can you please let me know what value did you pass to mandatory parameter "format" of escape function?

Former Member
0 Likes

You can use format = cl_abap_format=>e_xss_url. It should work.

Regards

Jaro

former_member226
Employee
Employee
0 Likes

Thanks Jaro.

jonathan_viau
Advisor
Advisor
0 Likes

Hello Jaro,

I recommend opening a ticket on component BC-SRV-APS-EXT-BL for this issue.

Best regards,
Jonathan