0

I have the following curl request

curl -X PUT http://localhost:50005/did:corda:tcn:77ccbf5e-4ddd-4092-b813-ac06084a3eb0  -H 'content-type:multipart/form-data'  -F 'instruction=hgfhhf'

I am trying to read the instruction in my spring boot controller as seen below

@PutMapping(value = "{id}",
    produces = arrayOf(MediaType.APPLICATION_JSON_VALUE),
    consumes = arrayOf(MediaType.MULTIPART_FORM_DATA_VALUE))

fun createID(@PathVariable(value = "id") id: String,
    @RequestParam("instruction") instruction: String ) : ResponseEntity<Any?> 

But the code above returns

"status":400,"error":"Bad Request","exception":"org.springframework.web.multipart.support.MissingServletRequestPartException","message":"Required request part 'instruction' is not present"
tsarenkotxt
  • 3,231
  • 4
  • 22
  • 38

1 Answers1

1
  1. remove unused:
    consumes = arrayOf(MediaType.MULTIPART_FORM_DATA_VALUE)
    
  2. you have missed request param instruction (in reqeust), try this:

    curl -X PUT -G 'http://localhost:50005/did:corda:tcn:77ccbf5e-4ddd-4092-b813-ac06084a3eb0' -d 'instruction=hgfhhf'
    

    also take a look at CURL Command Line URL Parameters

tsarenkotxt
  • 3,231
  • 4
  • 22
  • 38