【发布时间】:2017-07-18 00:19:13
【问题描述】:
我不知道为什么我的代码不起作用,我已经尝试使用 Postman 并且工作正常:
但是对于RestTemplate,当它使用相同的端点时我无法得到响应...。
ResponseEntity<String> responseMS = template.exchange(notificationRestService, HttpMethod.DELETE, new HttpEntity<NotificationRestDTO[]>(arrNotif), String.class);
我试过用List 代替Array[]
当我提出PUT 请求时,它工作正常,但只有一个对象:
ResponseEntity<String> responseMS = template.exchange(notificationRestService, HttpMethod.PUT, new HttpEntity<NotificationRestDTO>(notificationDTO), String.class);
有什么帮助吗??谢谢!!
【问题讨论】:
-
你也应该使用
DELETE作为带有resttemplate的http方法吗? -
类似:
new RestTemplate().delete ( uri, params ). -
@MouadELFakir
restTemplate.exchange()也应该可以工作。据我所知,delete()API 不允许您发送请求正文。 -
Miguel,你能告诉我们
RestTemplate.exchang()调用的结果是什么吗?它会抛出异常还是其他什么? -
@g00glen00b 我只从 SoapUI 得到 400 null,在代码中抛出 Spring 类,我什么都看不到
标签: spring spring-boot resttemplate spring-rest