API and query parameters

712 views
Skip to first unread message

cedric....@motwin.com

unread,
Aug 21, 2015, 8:12:40 AM8/21/15
to KONG
Hello, 
I am using Kong 4.2 and I've got a question about query parameters.
I have registered my API with the "path" option as follow:

curl -i -X POST --url http://localhost:8001/apis/ --data 'name=stockmarket' --data 'target_url=http://demo-streamdataio.rhcloud.com/' --data 'path=/stockmarket/prices'

When I curl with no query params, that's ok. I get my result. But if I curl with a query param, I've got an error:

HTTP/1.1 404 Not Found
Date: Fri, 21 Aug 2015 12:03:38 GMT
Content-Type: application/json; charset=utf-8
Connection: close
Server: kong/0.4.2
Via: kong/0.4.2

{"public_dns":["demo-streamdataio.rhcloud.com"],"message":"API not found with these values","path":"\/stockmarket\/prices?foo=bar"}

I didn't expect to get a "404 Not Found" when querying the API with a query param but my result. Am I wrong with my expectation or is it a bug?

Thanks in advance,

Cédric.

cedric....@motwin.com

unread,
Aug 21, 2015, 9:06:54 AM8/21/15
to KONG, cedric....@motwin.com
Well, having a look at the code, I've managed to get something working by adding a '/':

curl -i -X GET --url "http://localhost:8000/stockmarket/prices/?toto=oto" --header 'Host: demo-streamdataio.rhcloud.com'

Nonetheless, I would tend to say it's a bug because most of the time you don't have a ended '/' before the '?' of the query param. Am I wrong?

Cédric.

PS: « faulty » code is in kong/resolver/access.lua ~ l. 156 (local m, err = ngx.re.match(request_uri, "^"..path.."/"))

David Carr

unread,
Aug 21, 2015, 11:17:45 AM8/21/15
to KONG, cedric....@motwin.com
This feels like a bug to me.

Ahmad Nassri

unread,
Aug 21, 2015, 12:42:14 PM8/21/15
to David Carr, KONG, cedric....@motwin.com
opened an issue here for easy tracking: https://github.com/Mashape/kong/issues/495

thanks for reporting.

Ahmad Nassri

unread,
Aug 21, 2015, 12:46:18 PM8/21/15
to KONG, cedric....@motwin.com
you can track this issue here: https://github.com/Mashape/kong/issues/495

thanks for reporting.

Thibault Charbonnier

unread,
Aug 21, 2015, 6:09:29 PM8/21/15
to KONG, cedric....@motwin.com
Hi,


Thanks for reporting.

Cédric Tran-Xuan

unread,
Aug 24, 2015, 2:53:43 AM8/24/15
to Thibault Charbonnier, KONG
Many thanks for the fix!

Cédric.


Reply all
Reply to author
Forward
0 new messages