Passing query parameters to Kong 0.14

I have configured my service and route following the guidelines at

Invoking directly:
$ curl http://x.x.x.x:9099/services/ContentsByName?name=test

Invoking via Kong:
$ curl -i -X GET --url http://y.y.y.y:8000/?name=test --header ‘Host: ContentsByName’

This works.

But this is not intuitive. I prefer it to be in the format of
$ curl http://y.y.y.y:8000/ContentsByName?name=test

Passing everything in the URL, rather than just the parameters, while sending the API name as a header. Kong used to support it in its \api option of 0.12 which is now deprecated.

Is there a way to achieve this? Why does Kong force us to send the service name as a header, rather than including that in the URL, as it used to be? It seems to be a downgrade to me from its previous api.

Am I doing something wrong? Posts such as suggest what I am doing is the only way with the services and routes in 0.14.

Please enlighten me.


Have you had a look at the Proxy Guide for 0.14? See the section on request path, which is what the link points to.


Following the link, I can get this work:
$ curl -i -X GET --url http://y.y.y.y:8000/ContentsByName?name=test --header ‘Host:

But what I want is,
$ curl http://y.y.y.y:8000/ContentsByName?name=test

In other words, I don’t want to pass a “Host” via the header. Is that possible? I know it was possible with the API entity that is now deprecated.

You do not have to specify a Host header if you do not specify a Route’s hosts property. Maybe we could help you better if you shared the configuration of the Route you are trying to match.

1 Like

Thanks a lot. I give my complete steps here:
My application server is in http:// xx.xx.xx.xx: 9099
My Kong is in http:// yy.yy.yy.yy

I am connecting to both xx.xx.xx.xx and yy.yy.yy.yy from my laptop (same network as xx.xx.xx.xx and yy.yy.yy.yy).

My base service URL is: http:// xx.xx.xx.xx: 9099/services/v4

First, I configure services in Kong (from yy.yy.yy.yy, the server where Kong is deployed):

$ curl -i -X POST --url http:// localhost:8001/services/ --data ‘name=v4’ --data ‘url=http://xx.xx.xx.xx:9099/services/v4’

HTTP/1.1 201 Created
Date: Thu, 16 Aug 2018 12:59:56 GMT
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Access-Control-Allow-Origin: *
Server: kong/0.14.0
Content-Length: 262


Then I configure the route:
$ curl -i -X POST --url http://localhost: 8001/services/v4/routes --data ‘paths[]=/’

HTTP/1.1 201 Created
Date: Thu, 16 Aug 2018 13:09:18 GMT
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Access-Control-Allow-Origin: *
Server: kong/0.14.0
Content-Length: 281


Now I try to access my service via Kong from my laptop,

$ curl -i -X GET --url http://yy.yy. yy.yy:8000/services/

HTTP/1.1 404 Not Found
Content-Length: 0
Connection: keep-alive
Date: Thu, 16 Aug 2018 13:12:04 GMT
Server: Jetty(8.1.7.v20120910)
X-Kong-Upstream-Latency: 3
X-Kong-Proxy-Latency: 0
Via: kong/0.14.0

Of course, I tried different paths such as
$ curl -i -X POST --url http://localhost: 8001/services/v4/routes --data ‘paths[]=/services’

$ curl -i -X POST --url http://localhost: 8001/services/v4/routes --data ‘paths=/services’

and different options for curl commands such as,
$ curl -i -X GET --url http:// yy.yy.yy.yy: 8000/services/v4

$ curl -i -X GET --url http:// yy.yy.yy.yy: 8000/services/v4/ContentsByName?name=test

If something I did is wrong, it should be in the step where I created the route, without Host, but with paths option set, from what I understood from the documentation you shared and your comments. (Because that is where I changed, the step where I create the service is just the same, as when I have to use the header to pass the full path to the service).

Could you please verify what went wrong?

Thank you.

The space inside my urls in my above post is intentional (I do not have them in my actual commands) because Kong Nation was complaining “Sorry, new users can post only 5 links”. So I had to create space to work-around this.

I figured out where was the error:
It should be,
$ curl -i -X POST --url http://localhost:8001/services/v4/routes --data ‘paths=/services/v4’

The steps,

  1. Create a Kong service, matching the base.
  2. Create a Kong route with the path, matching the path. (Don’t use the Host option when you are at this step, despite the given example).

http://yy.yy.yy.yy :8000/services/v4/myservice -> http://xx.xx.xx.xx :9099/services/v4/myservice
works neatly!

Thanks a lot for your timely reply in helping me resolve this on time!