简体   繁体   English

调试不适用于其他方法使用邮递员其他客户端的PUT

[英]debug not working for rest method PUT using postman rest client

I have two Uri's 我有两个乌里

POST : http://localhost:8080/applications/2851/involved-parties/1/contacts POST: http:// localhost:8080 / applications / 2851 / involved-parties / 1 / contacts
PUT : http://localhost:8080/applications/2851/involved-parties/1/contacts 放置: http:// localhost:8080 / applications / 2851 / involved-parties / 1 / contacts

I am trying to debug methods,I have added breakpoint for both methods at starting, started server in debug mode. 我正在尝试调试方法,我在启动时都为这两种方法添加了断点,以调试模式启动了服务器。 while sending json request using postman rest client for POST method cursor stop you at break point at POST method. 使用POST方法游标的邮递员休息客户端发送JSON请求时,将您停在POST方法的断点处。 but same request for PUT method does not work your cursor does not stop you at break point its directly giving response back to client. 但是对PUT方法的相同请求不起作用,您的光标不会在断点处使您停止,它会直接将响应返回给客户端。

@RequestMapping(value = "/applications/{applicationReferenceNumber}/involved-parties/{id}/contacts", method = RequestMethod.PUT)
@ResponseBody
public PutApplicationsResponse putContacts(@Valid @RequestBody final PutApplicationsRequest req,
        final BindingResult bind, @PathVariable(value = "applicationReferenceNumber") final Long arn,
        @PathVariable(value = "id") final Integer id, @RequestHeader final HttpHeaders httpHeaders,
        final HttpServletRequest reqHTTP) throws ContactsException, SQLException, MethodArgumentNotValidException,
                HttpMessageNotReadableException {

    reqHTTP.setAttribute(ExceptionConstants.ARN, arn);
    reqHTTP.setAttribute(ExceptionConstants.id, id);
    objMp = new ObjectMapper();

    if (bind.hasErrors()) {
        throw new MethodArgumentNotValidException(null, bind);
    }

FYI : I am testing negative scenario for both method eg length for id is 4 if I pass the 5 length for id then it has to return exception 仅供参考:我正在测试两种方法的否定情况,例如id的长度为4如果我通过id的5长度,则它必须返回异常

Regards, 问候,

Normally with a PUT request to update, the particular resource URI should be known. 通常,通过更新的PUT请求,应该知道特定的资源URI。 So say the client makes a request to: 因此,说客户提出以下要求:

http://blah.com/applications/{applicationReferenceNumber}/involved-parties/{id}/contacts

Our service will look up the the id passsed. 我们的服务将查找传递的ID。 If it can't be found, we return a 404 status code, as the resource doesn't exist. 如果找不到该资源,我们将返回404状态代码,因为该资源不存在。 If it does exist, then we update the contacts for the application id provided in the request. 如果确实存在,那么我们将更新请求中提供的应用程序ID的联系人。 If you wanted to create a contacts, where the URI is not known, then POST would be correct, and you'd send a application id representation to: 如果您想创建一个不知道URI的联系人,则POST将是正确的,并且您将应用程序ID表示发送至:

http://blah.com/applications/{applicationReferenceNumber}/involved-parties/{id}/contacts

So basically if resource is available and we are doing put operation it will update directly on the server and also it is idempotent so evrytime you fire PUT request it will not do any other changes where as POST will create new resource every time and hence it will go through the code all the time. 因此,基本上,如果资源可用并且我们正在执行放置操作,它将直接在服务器上更新,并且它是幂等的,因此每次启动PUT请求时,evrytime都不会做任何其他更改,因为POST每次都会创建新资源,因此它将一直检查代码。

在Postman中,您可能需要通过POST发送数据,然后将_method字段添加为请求的一部分。

_method:put

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用邮递员休息客户端发送对象以调用REST服务 - how to send object using postman rest client to call REST service 如何使用邮递员休息客户端发送对象以调用REST服务,以便它将使用适当的方法参数命中以下给定的方法? - how to send object using postman rest client to call REST service so that it will hit the below given method with proper method parameters? 如何使用邮递员休息客户端将邮递请求发送到以下邮递方法 - How to send post request to the below post method using postman rest client 如何使用postman调试其余的webservices maven项目? - How to debug my rest webservices maven project using postman ? 如何使用邮递员休息客户端将自定义dto作为休息api输入传递 - how to pass custom dto as rest api input using postman rest client 如何邮寄REST客户端原始json数据在POST,PUT调用中发送到服务器? - how postman REST Client raw json data is sent to server in POST, PUT calls? Web 客户端 PUT 请求返回 403,但 Postman 请求不返回 - Glassfish 上的 Jersey REST API - Web Client PUT request returns 403 but Postman request does not - Jersey REST API on Glassfish 通过Chrome中的POSTMAN Rest Client的Json数据 - Json data through POSTMAN rest client in chrome MicroProfile Rest客户端无法正常工作 - MicroProfile Rest Client not working Spring Rest Template创建多部分表单/数据客户端,就像邮递员一样抛出不可转换的异常 - Spring Rest Template creating multipart form/data client working like a postman throws non convertable exception
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM