Content-Type is not supported in Camel DELETE method?

余生长醉 提交于 2019-12-20 07:24:34

问题


How do i send content-type in Camel DELETE method. I have added the following way but It was not working correctly.

from("direct:start")
.setHeader(Exchange.HTTP_METHOD, simple("DELETE"))
.setHeader(Exchange.CONTENT_TYPE, simple("application/xml")) 
.setHeader(Exchange.HTTP_URI, simple("http://02.02.02.02:8080/rest/delete/student/688187"))
.to("http://emptyhost");

Could you please help me to resolve this issue?


回答1:


As in a delete operation, no content is sent, the Exchange.CONTENT_TYPE property should not be needed.

Please, try

from("direct:start")
    .setHeader(Exchange.HTTP_METHOD, simple("DELETE"))
    .to("http://02.02.02.02:8080/rest/delete/student/688187");

or

from("direct:start")
    .to("restlet:http://02.02.02.02:8080/rest/delete/student/688187?restletMethod=delete");

By the way, using delete in the URL is not the RESTful way and should be ommited.

EDIT:

Camel does not transfer the body to the request of a DELETE operation, as can be seen digging into the source code. Use a PUT operation instead. See my answer to your other SO.




回答2:


As this post mentions, camel can process body if request method is delete in HTTP method.

Camel version 2.19.0 in http4 component with deleteWithBody option. We could just add it to the URL and use the http method as DELETE



来源:https://stackoverflow.com/questions/22715289/content-type-is-not-supported-in-camel-delete-method

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!