问题
Seems like a bug in scribe. It is using java.net.HttpURLConnection which is limited to
/* valid HTTP methods */
private static final String[] methods = {
"GET", "POST", "HEAD", "OPTIONS", "PUT", "DELETE", "TRACE"
};
There's no easy way to override this part (to use apache httpClient for instance) and there's a constant in Scribe org.scribe.model.Verb.PATCH, which basically never works with the rest of scribe code as it is now.
Any easy workarounds?
回答1:
For the moment Im removing PATCH
from scribe list of available http verbs:
https://github.com/fernandezpablo85/scribe-java/commit/65ae79d2702ccb192161db8fc6d1edaa5df07be8
On the workaround side, I've found the jersey guys had the same issue and used reflection to get around it.
回答2:
you can use "x-http-method-override" header parameter to over ride HTTP Method please go through below sample code i was using using 'POST' method but overriding it with 'PATCH'
OAuthRequest request = new OAuthRequest(Verb.POST,url);
request.addHeader("x-http-method-override", "PATCH");
Service.signRequest(konyAccessToken, request);//service is OAuthService instance
String result = response.getBody();
this work for other HTTP Methods like DELETE,TRACE....
来源:https://stackoverflow.com/questions/21119913/scribe-patch-request-not-working