In our most recent post we talked about how to set up Kong in your environment. We will now take a look at how to set up an API abstraction service in Kong, so you can route your requests to backend fulfillment APIs.
In the example we look at today, we will set up a generic call for “Get Incident Ticket” and have it translated via Kong to a backend ServiceNow API call for ServiceNow Incident Management. You can use this example to set up similar API call translations to any microservice for any custom or commercial application.
Step 1 – Check to make sure the Kong service is up and running
kong health
kong start
curl -i
http://<kong_FQDN_or_IP>:8001/
Step 2 – Set up a Service in Kong for the ServiceNow Incident API
curl -i -X POST --url http://
<kong_FQDN_or_IP>
:8001/services --data 'name=servicenow-sample-get-incident' --data 'url=https://<servername>.service-now.com/api/now/table/incident?sysparam_limit=1'
Step 3 – Create a route service for the API endpoint
curl -i -X POST --url http://
<kong_FQDN_or_IP>
:8001/services/servicenow-sample-get-incident/routes --data 'hosts[]=itsm-server' --data 'paths[]=/get-incident' --data 'methods[]=GET'
Step 4 – Test the API routing call. Note that the API translation happens on port 8000 by default. You will also provide the username and password (if needed) for the translated service. In our case, we will be passing basic authentication credentials for ServiceNow.
curl -i -X GET --url http://localhost:8000/get-incident --header "Host: itsm-server" -u username:password
The output would return the JSON formatted response from ServiceNow, and would look similar to below:
{"result":[{"parent":"","made_sla":"true","caused_by":"","watch_list":"","upon_reject":"cancel","sys_updated_on":"2019-09-05 11:30:23","child_incidents":"0","hold_reason":"","approval_history":"","number":"INC0010001","resolved_by":"","sys_updated_by":"admin","opened_by":{"link":"https://itsm-server/api/now/table/sys_user/6816f79cc0a8016401c5a33be04be441","value":"6816f79cc0a8016401c5a33be04be441"},"user_input":"","sys_created_on":"2019-09-05 11:30:16","sys_domain":{"link":"https://itsm-server/api/now/table/sys_user_group/global","value":"global"},"state":"2","sys_created_by":"admin","knowledge":"false","order":"","calendar_stc":"","closed_at":"","cmdb_ci":"","delivery_plan":"","contract":"","impact":"3","active":"true","work_notes_list":"","business_service":"","priority":"5","sys_domain_path":"/","rfc":"","time_worked":"","expected_start":"","opened_at":"2019-09-05 11:30:16","business_duration":"","group_list":"","work_end":"","caller_id":"","reopened_time":"","resolved_at":"","approval_set":"","subcategory":"","work_notes":"","short_description":"keyva_snow_test","close_code":"","correlation_display":"","delivery_task":"","work_start":"","assignment_group":"","additional_assignee_list":"","business_stc":"","description":"keyva snow test description","calendar_duration":"","close_notes":"","notify":"1","service_offering":"","sys_class_name":"incident","closed_by":"","follow_up":"","parent_incident":"","sys_id":"c1341204dbf3b70045a1f26039961932","contact_type":"","reopened_by":"","incident_state":"2","urgency":"3","problem_id":"","company":"","reassignment_count":"0","activity_due":"","assigned_to":{"link":"https://itsm-server/api/now/table/sys_user/6816f79cc0a8016401c5a33be04be441","value":"6816f79cc0a8016401c5a33be04be441"},"severity":"3","comments":"","approval":"not requested","sla_due":"","comments_and_work_notes":"","due_date":"","sys_mod_count":"1","reopen_count":"0","sys_tags":"","escalation":"0","upon_approval":"proceed","correlation_id":"","location":"","category":"inquiry"}]}
This quick walk-through showed you how you can easily create an API abstraction layer using Kong for specific back-end fulfillment calls. You can create similar calls for any level of infrastructure and application APIs and build capabilities towards an Infrastructure-as-Code implementation.
Keyva helps organizations implement API abstraction and leverage it to deliver Infrastructure-as-Code. The team at Keyva has years of experience with Kong and other API abstraction tools. We also offer lunch-and-learn sessions for discussions around how other organizations are using these technologies and what use cases would work best for your organization. Please contact us if you’re interested in discussing API abstraction and how it can work for you.
Anuj joined Keyva from Tech Data where he was the Director of Automation Solutions. In this role, he specializes in developing and delivering vendor-agnostic solutions that avoid the “rip-and-replace” of existing IT investments. Tuli has worked on Cloud Automation, DevOps, Cloud Readiness Assessments and Migrations projects for healthcare, banking, ISP, telecommunications, government and other sectors.
During his previous years at Avnet, Seamless Technologies, and other organizations, he held multiple roles in the Cloud and Automation areas. Most recently, he led the development and management of Cloud Automation IP (intellectual property) and related professional services. He holds certifications for AWS, VMware, HPE, BMC and ITIL, and offers a hands-on perspective on these technologies.
Like what you read? Follow Anuj on LinkedIn at: https://www.linkedin.com/in/anujtuli/
Join the Keyva Community! Follow Keyva on LinkedIn at: