3

My rest api is.

@PutMapping(consumes = MediaType.MULTIPART_FORM_DATA_VALUEpath="/{referenceNumber}")
public void updateCard(@RequestHeader(value = tenantId) String theTenantId,
@PathVariable String referenceNumber,@RequestParam(value = "card")MultipartFile multipartFile,HttpServletRequest request)

I need to check the condition like without browsing the file.

my input format is

Headers :

tenantId : ***

Body : selecting "formdata" (Postman), "multipart-formdata" (AdvancedRestClient)

card : without browsing file

Then i am getting the following error in Postman.

 {
"timestamp": 1549351840816,
"status": 400,
"error": "Bad Request",
"exception": "org.springframework.web.multipart.support.MissingServletRequestPartException",
"message": "Required request part 'card' is not present",
"path": "/app-1.5.0/1.5/references/34a236d7-9305-402f-959d-8c83d5ededbb"
  }

If i try in the AdvancedRest client with same input

I am getting the different error.

  {
"timestamp": 1549352119229,
"status": 415,
"error": "Unsupported Media Type",
"exception": "org.springframework.web.HttpMediaTypeNotSupportedException",
"message": "Content type 'null' not supported",
"path": "/app-1.5.0/1.5/references/34a236d7-9305-402f-959d-8c83d5ededbb" 
  
  } 

Is there any reason for different outputs and can i check the api without browsing file.

Community
  • 1
  • 1
madhuri
  • 63
  • 8

1 Answers1

0
@PutMapping(consumes = MediaType.MULTIPART_FORM_DATA_VALUEpath="/{referenceNumber}")
public void updateCard(@RequestHeader(value = tenantId) String theTenantId,
@PathVariable String referenceNumber,@RequestPart(required = false,value = "card")MultipartFile multipartFile,HttpServletRequest request){

}

User @RequestPart instead of @RequestParam

Muhammad Waqas
  • 367
  • 3
  • 13
  • 1
    Thank you.. It is working.What is the difference between RequestPart and RequestParam in my case. – madhuri Feb 05 '19 at 10:03
  • @madhuri [Difference between `@RequestPart` and `@RequestParam`](https://stackoverflow.com/questions/38156646/using-requestparam-for-multipartfile-is-a-right-way) – Muhammad Waqas Feb 05 '19 at 10:10