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
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

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
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

Because the DevOps movement has redefined engineering responsibilities, SREs now have to become stewards of observability strategy.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Related

  • Jakarta NoSQL 1.0: A Way To Bring Java and NoSQL Together
  • Lifecycle Microservices With GenAI Tools
  • Minimizing Latency in Kafka Streaming Applications That Use External API or Database Calls
  • Contexts in Go: A Comprehensive Guide

Trending

  • Implementing Explainable AI in CRM Using Stream Processing
  • AI Agents: A New Era for Integration Professionals
  • Optimizing Serverless Computing with AWS Lambda Layers and CloudFormation
  • How to Introduce a New API Quickly Using Micronaut
  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 user avatar
Rohini Arun kumar
·
Sep. 23, 20 · Tutorial
Likes (3)
Comment
Save
Tweet
Share
4.1K 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.

Related

  • Jakarta NoSQL 1.0: A Way To Bring Java and NoSQL Together
  • Lifecycle Microservices With GenAI Tools
  • Minimizing Latency in Kafka Streaming Applications That Use External API or Database Calls
  • Contexts in Go: A Comprehensive Guide

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

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 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!