Qw4z1
Qw4z1

Reputation: 3030

Http PATCH with Spring Android

I am working against an API using Spring-Android but when I tried to do a PATCH I noticed there is no corresponding method in RestTemplate. The Docs advise me to use the exchange or execute but I have a hard time understanding how. Also PATCH does not seem to be included in the Spring-Android 1.0.1 HttpMethod.

Any ideas on how to proceed?

Upvotes: 2

Views: 740

Answers (1)

Ralph
Ralph

Reputation: 120761

Sometimes the code explain it best:

If you have understand what the method RestTemplage.postForEntity(String url, Object request, Class<T> responseType, Object... uriVariables) does, then have a look at the way how it is implemented.

public <T> ResponseEntity<T> postForEntity(String url, Object request,
                    Class<T> responseType, Object... uriVariables)
                    throws RestClientException {

    HttpEntityRequestCallback requestCallback = 
                                  new HttpEntityRequestCallback(request, responseType);
    ResponseEntityResponseExtractor<T> responseExtractor =
                                  new ResponseEntityResponseExtractor<T>(responseType);
    return execute(url, HttpMethod.POST, requestCallback, responseExtractor, uriVariables);
}

I hope you understand how you can map this example to other Http Methods.

If you have not added the spring code to your IDE, you can have a look this url for the RestTemplate code

Upvotes: 1

Related Questions