FreeKB - create a Service using curl
Kong - create a Service using curl

The curl POST command can be used to create a service. 


On the Kong server

If Kong is running on docker, refer to Kong - Docker container command line for the steps on how to issue commands in the Kong Docker container. Assuming you are using the default kong.conf file, the Kong Admin API will listen on port 8001.

If issuing this command on the Kong server, this command will create "foo-service".

curl -X POST "http://localhost:8001/services" --data 'name=example-service' --data 'url=http://www.example.com'

 


From a remote server

If issuing this command from a remote server, this command will create "foo-service".

curl -X POST "http://hostname:8000/admin-api/services" --data 'name=example-service' --data 'url=http://www.example.com'

 


Validation

If the service was successfully created, something like this should be displayed. Additionally, the cURL command can be used to ensure the service exists.

{
 "host":"www.example.com",
 "created_at":1584414186,
 "connect_timeout":60000,
 "id":"7a2081ea-f4f6-45bf-b9c2-85824d2a34a9",
 "protocol":"http",
 "name":"example-service",
 "read_timeout":60000,
 "port":80,
 "path":null,
 "updated_at":1584414186,
 "retries":5,
 "write_timeout":60000,
 "tags":null,
 "client_certificate":null
}

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter 05d3d in the box below so that we can be sure you are a human.




Comments

Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |