0

i am trying to call the api through feign client and upload the file along with some string parameter through MultipartFile.

This is my client code:

package com.abc;

import feign.codec.Encoder;

@FeignClient(url = "https://xys.com", name = "uploadfile", configuration = UploadFileFeign.MultipartSupportConfig.class)
public interface UploadFileFeign {

    @PostMapping(value = "leaveApplication", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public ObjectRestResponse<?> handleFileUpload(@RequestParam(value = "request") String request,
            @RequestPart(value = "file") MultipartFile srcFile);


    class MultipartSupportConfig {
        @Bean
        public Encoder feignFormEncoder() {
            return new FeignSpringFormEncoder();
        }

        @Bean
        public feign.Logger.Level multipartLoggerLevel() {
            return feign.Logger.Level.FULL;
        }
    }
}

Below is the API code which my client is calling.

@RequestMapping(value="/services/leaveApplication", method=Request.POST, produces = MediaType.MULTIPART_FORM_DATA_VALUE, headers="Accept=application/json")
public ResponseOutput leaveApplication(@RequestParam("request") String request, @RequestParam(value = "file", required=false) MultipartFile srcFile) throws Exception {
}

But i am getting error in response: 403 - Forbidden error. You do not have permission to access the /services/leaveApplication

Other api's which do not involve file upload are working fine.

Ashutosh
  • 111
  • 14

1 Answers1

0

Typo here :

Request mapping URL is : /services/leaveApplication

But you are accessing : /service/leaveApplication

Change service to services

Alien
  • 15,141
  • 6
  • 37
  • 57