DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
Securing Your Software Supply Chain with JFrog and Azure
Register Today

Trending

  • Knowing and Valuing Apache Kafka’s ISR (In-Sync Replicas)
  • Event-Driven Architecture Using Serverless Technologies
  • Integrating AWS With Salesforce Using Terraform
  • SRE vs. DevOps

Trending

  • Knowing and Valuing Apache Kafka’s ISR (In-Sync Replicas)
  • Event-Driven Architecture Using Serverless Technologies
  • Integrating AWS With Salesforce Using Terraform
  • SRE vs. DevOps
  1. DZone
  2. Data Engineering
  3. Databases
  4. How to Access URI and Query Parameter Inside Kumologica API

How to Access URI and Query Parameter Inside Kumologica API

Understanding the usage of URI and query parameter is very important when developing an API. Read on to find out how!

Rohini Arun kumar user avatar by
Rohini Arun kumar
·
Sep. 23, 20 · Tutorial
Like (3)
Save
Tweet
Share
3.61K Views

Join the DZone community and get the full member experience.

Join For Free

access URI

As an API developer, you would have designed and developed REST APIs that are intended to do some action over a particular resource, retrieval, or filtering of a collection of resources. These actions in the REST world are typically done with the help of a URI or query parameter. Understanding the usage of URI and query parameter is very important when developing an API.

URI Parameter

A URI is a resource identifier that can uniquely identify a specific instance of a resource. URI is part of the URL that is passed to get a unique resource.

eg: Get the details of a credit or debit card with unique id 738288383 and 489393 respectively.

http://abc.com/card/credit/738288383

http://abc.com/card/debit/489393

Query Parameter

Query parameters are used for filtering a resource collection. They are passed at the end of the URL after a question mark to sort, filter, or paginate the resource. In certain cases, they are also used along with the URI parameter.

eg: Get the credit cards that are in an active state and limit it by 100 cards.

http://abc.com/card/credit?status=active&limit=100

Now I think you might have got some idea around when to use URI and query parameter. In this article, I will demonstrate how to extract the URI and query parameter values inside the Kumologica API flow. For this, we will create two flows. The first flow will demonstrate how to access the URI parameter and the second flow will demonstrate how to access the query parameter.

Pre-Requisite

  1. Download and install the Kumologica designer.
  2. Install and configure AWS CLI

Note: For more details on installation refer to the following link.

Steps

Lets first see how to access the URI parameter inside an API flow developed using Kumologica.

  1. Drag and drop the Event Listener node from the palette and configure the following by opening the node settings.
Event Source: Amazon API Gateway
Verb: GET
Path: /card/credit/:cardno

In the above configuration, Path is having:cardno as the notation to represent the URI parameter cardno.

2. Place the Logger node from the palette and provide the following as the Message. This will print the URI parameter in the AWS Cloudwatch log by default.

Message: msg.header.event.Records[0].pathParameters.cardno

In the above Kumologica expression, we are traversing the AWS lambda event payload.

3. Add EventListener End node to the canvas and set the Payload as given below. This will return the URI parameter as the plain text response

Content-Type: text/plain
Payload :
msg.header.event.Records[0].pathParameters.cardno

4. Wire all the 3 nodes and will be getting the flow assembly as given below.

logger

Now let's create the second flow to access the query parameter inside an API flow.

  1. Drag and drop the Event Listener node from the palette and configure the following by opening the node settings.
Event Source: Amazon API Gateway
Verb: GET
Path: /card/credit

2. Place the Logger node from the palette and provide the following as the Message. This will print the query parameter in the AWS Cloudwatch log by default.

Message: msg.header.event.Records[0].queryStringParameters.status

In the above Kumologica expression, we are traversing the AWS lambda event payload to fetch the query parameter.

3. Add EventListener End node to the canvas and set the Payload as given below. This will return the query parameter as the plain text response

Content-Type: text/plain
Payload:
msg.header.event.Records[0].queryStringParameters.limit

4. Wire all the 3 nodes and will be getting the flow assembly as given below.

logger

Deploy and Test

  1. Go to the cloud tab and select the AWS profile.
  2. Go to the trigger section and selection API Gateway as the trigger and set the following.
API: Create new API
Deployment stage: test

3. Click Deploy. Once deployed copy the URL for testing.

4. Go to POSTMAN or any rest client of your choice and provide the below.

GET https://fjdj383ij.amazonaws.com/test/card/credit/28892933

You should get the response as 28892933.

5. Go back to POSTMAN and provide the below.

GET https://fjdj383ij.amazonaws.com/test/card/credit/?status=active&limit=100

You should get the response as 100.

In the AWS CloudWatch logs, you can also see the logger printing the card number (first flow) and status (second flow).

Summary

I hope you have enjoyed the article and able to understand the concept of URI and query parameter and the way to access both the values inside Kumologica flow. Please share your valuable feedback and queries on the comments box and see you in my next article. Thank you.

Uniform Resource Identifier API Database

Opinions expressed by DZone contributors are their own.

Trending

  • Knowing and Valuing Apache Kafka’s ISR (In-Sync Replicas)
  • Event-Driven Architecture Using Serverless Technologies
  • Integrating AWS With Salesforce Using Terraform
  • SRE vs. DevOps

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com

Let's be friends: