HttpMediaTypeNotAcceptableException当application / json-patch + json用作' Content-Type'头

时间:2016-05-10 21:53:32

标签: spring rest spring-boot

我们正在使用补丁操作来支持部分更新。

@ApiOperation(value="Patch (Partial Update) user payment")
@RequestMapping(method = RequestMethod.PATCH, consumes = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<UserPaymentInfo> patchPaymentInfo(@ApiParam(value = "The user id", required = true)@PathVariable final String uid,
                             @ApiParam(value = "Whether to reteurn new payment info back") @RequestParam(name = "includeResponse", defaultValue = "false") final boolean includeResponse,@ApiParam(value = "Description of changes")@RequestBody final String userPaymentInfoPatchJson) {
    UserPaymentInfo paymentInfo = userPaymentService.patchPaymentInfo(uid,userPaymentInfoPatchJson,includeResponse);
    HttpStatus status = includeResponse ? HttpStatus.OK : HttpStatus.NO_CONTENT;
    return new ResponseEntity<>(paymentInfo,status);
}

下面提到的是例外:

    {"code": "0000",
"message": "Could not find acceptable representation (HttpMediaTypeNotAcceptableException)",
  "host": "localhost",
  "url": "/users/000020800464/paymentinfo/test",
  "method": "PATCH",
  "causes": [
    {
      "code": "0000",
      "message": "Could not find acceptable representation (HttpMediaTypeNotAcceptableException)"
    }
  ]
}

同一个端点适用于application / json作为Content-Type的标头值,但是&#39; application / json-patch + json&#39;失败。

spring boot是否支持补丁bcs我无法找到org.springframework.http.MediaType.java中提到的相关标题名称

0 个答案:

没有答案