getting 302 error when calling an api services using open feignclient
04:15 31 Mar 2026

I have been working on Microservices learning path. Trying to call address service from employee service using Open feign in eureka client program, but I'm encountering this error message:

Request processing failed: feign.FeignException: \[302\] during \[GET\] to \[http://address-service/address-app/api/address/1\] \[AddressClient#getAddressByEmployeeId(Integer)\]: \[\[{"addressId":1,"addressLine1":"addressline 1","addressLine2":"addressLine2","cityName":"city","employeeId":1,"stateName":"state","zipCode":"021547"},{"addressId":3,"addressLine1":"addressline1","addressLine2":"addressLine2","cityName":"city","employeeId":1,"stateName":"state","zipCode":"236525"}\]\]\] with root cause

feign.FeignException: \[302\] during \[GET\] to \[http://address-service/address-app/api/address/1\] \[AddressClient#getAddressByEmployeeId(Integer)\]: \[\[{"addressId":1,"addressLine1":"addressline1","addressLine2":"addressline2","cityName":"city","employeeId":1,"stateName":"state","zipCode":"021547"},{"addressId":3,"addressLine1":"addreessLine1","addressLine2":"addressLine2","cityName":"city","employeeId":1,"stateName":"state","zipCode":"236525"}\]\]

But in separate, API calls are working fine.

Please find the some code snippets.

I request your expertise on fixing the issue.

Address Services#
package com.spring.cloud.asign;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;

@SpringBootApplication
@EnableDiscoveryClient
public class AddressServiceApplication {

    public static void main(String[] args) {
        SpringApplication.run(AddressServiceApplication.class, args);
    }
}

spring.application.name=address-service
server.servlet.context-path=/address-app/api
server.port=8080

spring.datasource.url=jdbc:postgresql://localhost:5432/postgres?currentSchema=asignaddrservice
spring.datasource.username=postgres
spring.jpa.hibernate.ddl-auto=update
Employee Services#
package com.spring.cloud.asign;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;

@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
public class EmployeeServiceApplication {

    public static void main(String[] args) {
        SpringApplication.run(EmployeeServiceApplication.class, args);
    }
}

spring.application.name=employee-service
server.servlet.context-path=/employee-app/api
server.port=8085

# --- Datasource Connection ---
spring.datasource.url=jdbc:mysql://localhost:3306/employee-management
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.username=root

# --- JPA & Hibernate Settings ---
spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect
spring.jpa.hibernate.ddl-auto=update
#spring.jpa.show-sql=true

package com.spring.cloud.asign.client;

import java.util.List;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import com.spring.cloud.asign.model.AddressResponse;

@FeignClient(value = "address-service", path = "/address-app/api")
public interface AddressClient {
    
    @PostMapping("/address")
    public AddressResponse addAddress(@RequestBody AddressResponse addRes);
    
    @GetMapping("/address/{empId}")
    public List getAddressByEmployeeId(@PathVariable Integer empId);
    
    @GetMapping("/address")
    public List getAllAddress();
}

package com.spring.cloud.asign.services;

import java.util.List;
import java.util.stream.Collectors;

import org.modelmapper.ModelMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.spring.cloud.asign.client.AddressClient;
import com.spring.cloud.asign.entity.Employees;
import com.spring.cloud.asign.model.AddressResponse;
import com.spring.cloud.asign.model.EmployeeResponse;
import com.spring.cloud.asign.repo.EmployeeRepository;

@Service
public class EmployeeServices {
    
    @Autowired
    private EmployeeRepository employeeRepository;
    
    @Autowired
    private ModelMapper modelMapper;
    
    @Autowired
    private AddressClient addClient;
    
    
    public EmployeeResponse fetchEmployee(Integer empId) {
        
        Employees emp = employeeRepository.findById(empId).orElseThrow();
        
        List addrRes = addClient.getAddressByEmployeeId(empId);
        
        EmployeeResponse empResponse = modelMapper.map(emp, EmployeeResponse.class);
        empResponse.setAddResList(addrRes);
        
        return empResponse;     
    }
}
spring-boot microservices openfeign