cancel
Showing results for 
Search instead for 
Did you mean: 

Handling of multiple query parameter values in external HTTP GET request

szeller
Explorer
0 Kudos
1,303

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

Accepted Solutions (1)

Accepted Solutions (1)

szeller
Explorer

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!

Answers (2)

Answers (2)

juliandanho
Participant

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

Sandra_Rossi
Active Contributor

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.

szeller
Explorer
0 Kudos

Thanks for the hint regarding the escape character %2c - it was a typo when writing this question.

Escaping using the standard ways "escape( )" or "cl_http_utility=>escape_url( .. )" did not solve the issue.

Any other ideas? Thank you in advance!

junwu
Active Contributor
0 Kudos

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.

szeller
Explorer
0 Kudos

Thanks for the suggestion, but backend expects the inner double quotation marks. param1="VALUE1,VALUE2" does not work.

szeller
Explorer
0 Kudos

And yes, I am sure that this exact query works in Postman.