我有以下卷曲请求
curl -X PUT http://localhost:50005/did:corda:tcn:77ccbf5e-4ddd-4092-b813-ac06084a3eb0 -H 'content-type:multipart/form-data' -F 'instruction=hgfhhf'
我正尝试阅读我的spring boot控制器中的指令,如下所示
@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?>
但是上面的代码返回了
"status":400,"error":"Bad Request","exception":"org.springframework.web.multipart.support.MissingServletRequestPartException","message":"Required request part 'instruction' is not present"
答案 0 :(得分:1)
consumes = arrayOf(MediaType.MULTIPART_FORM_DATA_VALUE)
您错过了请求参数说明(需要),请尝试以下操作:
curl -X PUT -G 'http://localhost:50005/did:corda:tcn:77ccbf5e-4ddd-4092-b813-ac06084a3eb0' -d 'instruction=hgfhhf'