CoderSathi
  • Tutorial
    • Java Tutorial
    • Swing Tutorial
    • JDBC Tutorial
    • Java String Tutorial
    • Servlet and JSP Tutorial
  • Mongo DB
  • AWS
  • DevOps
  • Linux
  • Git
Home > Java > Send Java Object as Request Parameter Using Feign Client

Java Tutorial

  • Introduction
    • What is Java
    • History Of Java
    • Install Java
    • What is JVM
    • JDK vs JRE vs JVM
    • Java Bytecode
    • OOP vs POP
    • Compile and Run Java
  • Tokens, Expressions and Control Structures
    • Primitive data types
    • Integers
    • Floating Points
    • Characters
    • Booleans
    • User Defined Data Type
    • Declarations
    • Constants
    • Identifiers
    • Literals
    • Type Conversion and Casting
    • Variables
    • Default Variable Initialization
    • Command Line Arguments
    • Arrays of Primitive Types
    • Comment Syntax
    • Garbage Collection
    • Expressions
    • Operators
    • Arithmetic Operator
    • Bitwise and Shift Operator
    • Comparison or Relational Operators
    • Logical Operators
    • Assignment Operators
    • Ternary Operator
    • Increment and Decrement Operator
    • Control Statements
  • OOP Concepts
    • Class and Object
    • Create Class Instance
    • Method
    • Abstraction
    • Encapsulation
    • this keyword
    • Constructor
    • Pass by Value
    • Access Modifier/Control
    • Polymorphism
    • Method Overloading vs Method Overriding
    • Recursion
    • Nested and Inner Class
  • Inheritance and Packaging
    • Inheritance
    • extends Keyword
    • super Keyword
    • Object Class
    • Abstract class
    • Final Class
    • Java Package
    • Interface
  • Handling Error/ Exceptions
    • What is Exception
    • Exception Handling Keywords
    • Common Java Errors
    • User Defined Exception
    • Throwing and re-throwing Exception
    • finally Block
  • Strings
    • Java String Tutorial
  • Threads
    • Introduction
    • Create Thread
    • Thread Lifecycle
    • Thread Priority
    • Thread Synchronization
    • Inner Thread Communication
    • Thread Deadlock
  • IO and Streams
    • java.io Package
    • Files and Directories
    • Byte Stream
    • Character Stream
    • Console Input and Output
    • Serializable and Deserializable
  • Core Packages
    • java.lang Package
    • Math
    • Wrapper Classes
    • java.lang.Number
    • Double
    • Float
    • Integers
    • java.lang.Byte
    • java.lang.Short
    • java.lang.Long
    • java.lang.Character
    • java.lang.Boolean
    • java.util package
    • Vector Class
    • Stack Class
    • Dictionary Class
    • Hashtable
    • Enumeration or Enum
    • Generate Random Number
  • Holding Collection of Data
    • Arrays
    • Map
    • List
    • Set
    • Collection Interface
    • Collections Class
    • ArrayList
    • HashSet
    • TreeSet
    • Comparator
  • Java Bean
    • What is Java Bean
    • Advantages and Disadvantages of Java Bean
    • Java Beans API
    • Introspection
    • Java Bean Properties
    • Bound and Constrained Properties
    • BeanInfo Interface
    • Customizers
    • Java Beans Persistence
    • BeanDescriptor
  • Home

Send Java Object as Request Parameter Using Feign Client

Learn the concepts, implementation details, and practical steps with a clean developer-focused walkthrough.

Yuba Raj Kalathoki
By Yuba Raj Kalathoki
Last updated: July 1, 2026 ยท 2 min read ยท 0 Comments
Share: in X

When working with Spring Boot and Spring Cloud, Feign clients make it easy to communicate with other microservices. However, passing Java objects as query parameters can be tricky. By default, Feign treats objects as request bodies, but what if you want each field of an object to be a separate query parameter? The @SpringQueryMap annotation is your solution!

Table of Contents

  • The Problem
  • The Solution: @SpringQueryMap
  • Step-by-Step Guide
    • Define Your Java Class
    • Feign Client Interface
    • Controller Class
  • Conclusion

The Problem

Consider a scenario where you need to send a Java object with multiple fields as individual query parameters in a GET request. Normally, Spring Boot REST controllers handle this seamlessly, but Feign clients require a bit more configuration.

The Solution: @SpringQueryMap

With the @SpringQueryMap annotation from Spring Cloud OpenFeign, you can easily map object fields to query parameters. Following is the step by step guide to achieve this:

Step-by-Step Guide

Define Your Java Class

This is the class to send as request parameter object.

public class MyRequest {
    private String param1;
    private int param2;
    // Getters and Setters
}

Feign Client Interface

import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@FeignClient(name = "myClient")
public interface MyClient {
    @RequestMapping(method = RequestMethod.GET, value = "/myEndpoint")
    String callMyEndpoint(@SpringQueryMap MyRequest myRequest);
}

Controller Class

@RestController
public class MyController {

    @GetMapping("/testFeign")
    public String callMyEndpoint(MyRequest request) {
        //implement your logic here.
    }
}

Conclusion

With @SpringQueryMap, we can effortlessly pass Java objects as query parameters in your Feign clients. This powerful annotation simplifies the process, making our code cleaner and more maintainable.

Related Posts:

  • Most Frequently Asked Spring Boot Interview…
  • Spring Data REST example.
  • How to Use AWS CloudFront Signed URLs in Spring Boot?
  • How to Define FeignClient URL in Spring Boot for…
  • Array Operator in MongoDB
  • Control Statements in Java
Tags:feign-clientjavaspring-boot
Was this article helpful?
โ† Previous ArticleHow to Perform Case-Insensitive Sorting in MongoDB Using Java?
Next Article โ†’How to Write User Stories and Acceptance Criteria: A Comprehensive Guide

Leave a Comment Cancel reply

You must be logged in to post a comment.

Recent Posts

  • How to implement Passwordless Authentication in Spring Boot: A Step-by-Step Guide
  • How to Use AWS CloudFront Signed URLs in Spring Boot?
  • How to Fix SSH Agent Forwarding on macOS: The Ultimate Guide for Developers
  • How to Read AWS Secrets Manager in Spring Boot (Step-by-Step)
  • How to Fix “Public Key Retrieval is not allowed” MySQL JDBC Error
CoderSathi

Your go-to resource for Java, Spring Boot, Microservices, AWS, and modern development tutorials.

Linkedin

Quick Links

  • About
  • Contact

Popular Topics

  • Java
  • Spring Boot
  • AWS
  • DevOps
  • MongoDB
  • Linux
  • Git
  • How to
ยฉ 2026 CoderSathi. All rights reserved. Privacy Policy ยท Sitemap