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
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Adding Graph Retrieval to a RAG Pipeline With Python
  • Microservices Architecture in Production: 7 Engineering Decisions That Determine Success or Failure
  • The Bill You Didn't See Coming
  • Push Filters Down, Not Up: The Data Layer Design Principle Most Developers Learn Too Late

Trending

  • Closing the Drift Loop: An AI Agent That Drafts Terraform Fixes
  • Giving AI Agents Safe Access to Legacy Systems: Introducing legacy2mcp
  • 5 Proven Strategies for Modernizing Legacy .NET Applications
  • A Walk-Through of the DZone Article Editor

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  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!

By 
Rohini Arun kumar
·
Sep. 23, 20 · Tutorial
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
4.3K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

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.

Related

  • Adding Graph Retrieval to a RAG Pipeline With Python
  • Microservices Architecture in Production: 7 Engineering Decisions That Determine Success or Failure
  • The Bill You Didn't See Coming
  • Push Filters Down, Not Up: The Data Layer Design Principle Most Developers Learn Too Late

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

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

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook