You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Kris Boutilier (Jira)" <ji...@apache.org> on 2020/08/13 16:28:00 UTC

[jira] [Comment Edited] (CAMEL-15410) REST endpoint has inconsistent URL Encoding

    [ https://issues.apache.org/jira/browse/CAMEL-15410?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17177130#comment-17177130 ] 

Kris Boutilier edited comment on CAMEL-15410 at 8/13/20, 4:27 PM:
------------------------------------------------------------------

It's not immediately clear if it's related to the above, but I'm also having issues with + vs %20 encoding of spaces when passed in via headers and, because the target server is pedantic, requests that use application/x-www-form-urlencoded style encoding are failing.

For example, this:
{code:java}
.setHeader("filter", simple("date(time/date) ge 2020-06-01 and personId eq 'R10019'"))
.to("rest:get:bw-web-api/v1/objects/timesheets?host=agresso&companyId=RD&select={select}&filter={filter}&onWorkFlow=true&noWorkflow=true") 
{code}
results in a payload of:
{code:java}
GET /bw-web-api/v1/objects/timesheets?companyId=RD&filter=date%28time%2Fdate%29+ge+2020-06-01+and+personId+eq+%27R10019%27&noWorkflow=true&onWorkFlow=true&select=personId%2Cperiod%2Ctime%28*%29 HTTP/1.1\r\n{code}
however the server is expecting to see this encoding:
{code:java}
GET /bw-web-api/v1/objects/timesheets?companyId=RD&filter=date%28time%2Fdate%29%20ge%202020-06-01%20and%20personId%20eq%20%27R10019%27&onWorkflow=true&noWorkflow=true&select=personId%2Cperiod%2Ctime%28*%29 HTTP/1.1\r\n{code}
 


was (Author: kris.boutilier@gmail.com):
It's not immediately clear if it's related to the above, but I'm also having issues with + vs %20 encoding of spaces when passed in via headers and, because the target server is pedantic, requests that use application/x-www-form-urlencoded style encoding are failing.

For example, this:
{code:java}
.setHeader("filter", simple("date(time/date) ge 2020-06-01 and personId eq 'R10019'")).to("rest:get:bw-web-api/v1/objects/timesheets?host=agresso&companyId=RD&select={select}&filter={filter}&onWorkFlow=true&noWorkflow=true") 
{code}
results in a payload of:
{code:java}
GET /bw-web-api/v1/objects/timesheets?companyId=RD&filter=date%28time%2Fdate%29+ge+2020-06-01+and+personId+eq+%27R10019%27&noWorkflow=true&onWorkFlow=true&select=personId%2Cperiod%2Ctime%28*%29 HTTP/1.1\r\n{code}
however the server is expecting to see this encoding:
{code:java}
GET /bw-web-api/v1/objects/timesheets?companyId=RD&filter=date%28time%2Fdate%29%20ge%202020-06-01%20and%20personId%20eq%20%27R10019%27&onWorkflow=true&noWorkflow=true&select=personId%2Cperiod%2Ctime%28*%29 HTTP/1.1\r\n{code}
 

> REST endpoint has inconsistent URL Encoding 
> --------------------------------------------
>
>                 Key: CAMEL-15410
>                 URL: https://issues.apache.org/jira/browse/CAMEL-15410
>             Project: Camel
>          Issue Type: Bug
>          Components: rest
>    Affects Versions: 3.4.2
>            Reporter: Kris Boutilier
>            Priority: Minor
>
> When passing query parameters to a REST producer the encoding behavior is inconsistent. Consider the following:
> {code:java}
> .to("rest:get:bw-web-api/v1/objects/employees?host=agresso&companyId=RD&select=personId,personName&disconnect=true")
> {code}
> The resulting request payload, as observed with Wireshark, is:
> {code:java}
> GET /bw-web-api/v1/objects/employees?companyId=RD&disconnect=true&select=personId%252CpersonName HTTP/1.1\r\n{code}
> Note that the comma has been double-encoded resulting in transmission of %252C instead of the expected %2C.
> If instead the problem string is passed as a parameter via a header, the comma is correctly escaped:
> {code:java}
> .setHeader("select", simple("personId,personName"))
> .to("rest:get:bw-web-api/v1/objects/employees?host=agresso&companyId=RD&select={select}&disconnect=true") {code}
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)