on 2023 Jun 20 7:01 PM
Hi community,
I am performing a HTTP GET request from my ABAP report to an External HTTP service (using class CL_HTTP_CLIENT). Business logic requires multiple values for same query parameter (i.e. condition: VALUE1 or VALUE2) and the External HTTP service requires parameter values to be embraced by double quotation marks, c.f. following example:
https://external-service.com/rest/endpoint/search?param1="VALUE1","VALUE2";
Unfortunately, this request does not return any result in my ABAP report. Yet, this exact same request works well in Postman and returns corresponding results as expected. Thus, I conclude that issue is not related to the External Service.
Sending separate requests with single values - i.e.
https://external-service.com/rest/endpoint/search?param1="VALUE1";
and
https://external-service.com/rest/endpoint/search?param1="VALUE2";
works well in my ABAP report. But, this is just a test and sending separate requests is no final solution for the actual report.
I also tried escaping the double quotation marks like
https://external-service.com/rest/endpoint/search?param1=%22VALUE1%22,%22VALUE2%22
or even
https://external-service.com/rest/endpoint/search?param1=%22VALUE1%22%44%22VALUE2%22
but this does not change anything.
My personal hypothesis:
Issue is caused by handling of inner double quotation marks and by transferring one condensed parameter value like
?param1="VALUE1%22,%22VALUE2"
Any ideas how to solve this issue?
Thank you in advance!
Kind Regards
Sebastian
Reference: SAPK-75702INSAPBASIS, SAP Kernel 789 PL 100
Request clarification before answering.
ICM Monitor shows that the parameter is indeed transferred as
?param1=%22VALUE1%22%2c%22VALUE2%22
It is RFC3986 compliant on SAP side.
Based on your hint regarding RFC3986 compliance, I tested some additional parameter strings in Postman:
?param1="VALUE1","VALUE2" works (as written in the initial question)
?param1=%22VALUE1%22%,%22VALUE2%22 works
?param1="VALUE1"%2c"VALUE2" does not work
?param1=%22VALUE1%22%2c%22VALUE2%22 does not work
Apparently, the service is not able to handle the RFC3986 compliant escaped comma (%2c). I will reach out to the service desk of the company.
Thank you sandra.rossi!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi szeller
your esacping of param "%22VALUE1%22%44%22VALUE2%22" is not right. %44 = D (%2c = ,). Use the ABAP class CL_HTTP_UTILITY for esacping/unescaping you params. In the class you have the static methods escape_url and unescape_url.
DATA(url) = |https://external-service.com/rest/endpoint/search?{ cl_http_utility=>escape_url( unescaped = |"VALUE1","VALUE2"| ) }|.
I hope this will help you.
Kind regards
Julian Danho
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Also:
...search?{ escape( val = |...| format = cl_abap_format=>e_uri_full ) }|.
NB: not sure why SAP has decided that E_URI_FULL should be the only one (among all E_URI* and E_URL* formats) to percent encode the comma.
are you sure param1="VALUE1","VALUE2" this one works in postman?
param1="VALUE1,VALUE2" normally backend will expect this kind of string for multiple value.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the suggestion, but backend expects the inner double quotation marks. param1="VALUE1,VALUE2" does not work.
User | Count |
---|---|
53 | |
6 | |
6 | |
5 | |
5 | |
5 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.