Reputation: 33
I am trying to update one column using http-method "PATCH" and I get the below error. The code is -
<int:chain input-channel="updateChannel">
<int:service-activator ref="trackingNumberProcessor" method="message"/>
<int-http:outbound-gateway url="http://test.com/consumerappointment/appointments/1295" http-method="PATCH" expected-response- type="java.lang.String" charset="UTF-8">
</int-http:outbound-gateway>
</int:chain>
Caused by: org.springframework.web.client.ResourceAccessException: I/O error on PATCH request for "http://test.com/consumerappointment/appointments/1295":Invalid HTTP method: PATCH; nested exception is java.net.ProtocolException: Invalid HTTP method: PATCH
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:561) ~[spring-web-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:521) ~[spring-web-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:466) ~[spring-web-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.integration.http.outbound.HttpRequestExecutingMessageHandler.handleRequestMessage(HttpRequestExecutingMessageHandler.java:421) ~[spring-integration-http-4.0.0.RELEASE.jar:na]
... 62 common frames omitted
Caused by: java.net.ProtocolException: Invalid HTTP method: PATCH
at java.net.HttpURLConnection.setRequestMethod(HttpURLConnection.java:428) ~[na:1.7.0_51]
at org.springframework.http.client.SimpleClientHttpRequestFactory.prepareConnection(SimpleClientHttpRequestFactory.java:213) ~[spring-web-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.http.client.SimpleClientHttpRequestFactory.createRequest(SimpleClientHttpRequestFactory.java:141) ~[spring-web-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.http.client.support.HttpAccessor.createRequest(HttpAccessor.java:76) ~[spring-web-4.0.6.RELEASE.jar:4.0.6.RELEASE]
Upvotes: 3
Views: 3020
Reputation: 121177
Caused by: java.net.ProtocolException: Invalid HTTP method: PATCH at java.net.HttpURLConnection.setRequestMethod(HttpURLConnection.java:428) ~[na:1.7.0_51] at org.springframework.http.client.SimpleClientHttpRequestFactory.prepareConnection(SimpleClientHttpRequestFactory.java:213) ~[spring-web-4.0.6.RELEASE.jar:4.0.6.RELEASE]
Use HttpComponentsClientHttpRequestFactory
instead:
<int-http:outbound-gateway url="http://test.com/consumerappointment/appointments/1295"
http-method="PATCH"
expected-response-type="java.lang.String"
request-factory="clientHttpRequestFactory"
charset="UTF-8" />
<beans:bean id="clientHttpRequestFactory" class="org.springframework.http.client.HttpComponentsClientHttpRequestFactory"/>
Upvotes: 2