Java控制器未接收到来自Postman的PUT请求

问题描述 投票:1回答:1

我已经在控制器[GET,POST和PUT]中编写了多个REST端点。

GET和POST调用工作正常。但是,当我尝试从Postman发出PUT请求时,我的Java控制器无法接收该请求。没有错误信息。响应正文为空。邮递员的响应代码为200,确定。

这里是我的PUT端点,无法从邮递员那里获得请求:

@PutMapping(value = "/devRegistration")
public Object deviceRegistration(HttpServletRequest httpRequest,  
        @RequestBody(required = false) Map<String, Object> jsonBody ){

    ResponseEntity<Object> response = null;
    System.out.println("jsonBody = "+jsonBody);
    devService.deviceRegistration(httpRequest, jsonBody);

    return response;
}

这里是我的GET端点,它运行正常:

@GetMapping(value = "/checkRegistration")
public void checkRegistration(HttpServletRequest httpRequest,  
        @RequestParam("appId") String appId, @RequestParam("offset") String offset  ){

    Map<String, Object> jsonBody = new HashMap<String, Object>();
    jsonBody.put("appId", appId);
    jsonBody.put("offset", offset);
    service.checkRegistration(httpRequest, jsonBody);
}

带有用于PUT请求的标题和正文的邮递员URL为:

https://localhost:8443/api/device/devRegistration
In Body:
app_Id : some value
offset : some value

Headers are:

RequestHeader
Content-Type
Authorization
MobileHeader
SessionToken

但是,System.out.println()不在PUT端点中执行。

让我知道,如果还有其他信息。是必需的。

rest postman put
1个回答
0
投票

我找到了答案。

实际上,我需要将正文中的参数作为原始格式而不是邮递员中的表单数据进行传递。

现在有效。

© www.soinside.com 2019 - 2024. All rights reserved.