Search code examples
scribe

Is there any work around for using PATCH method in scribe


Scribe PATCH request not working

i have gone through the jersey guys workaround but i was not certain how i can use that in my logic as per there work around we need java.net.HttpURLConnection object but this was private member of request class in scribe Below logic i was trying to implement

OAuthRequest request = new OAuthRequest(Verb.PATCH,url);
Service.signRequest(konyAccessToken, request);//service is OAuthService instance
String result = response.getBody();

Currently i am getting error as PATCH was not supported by scribe(as it uses HttpURLConnection) how can i achieve this using above work around (or any other workaround)

Thanks in advance Surya


Solution

  • It take me while to figure it out but finally got solution we can override the HTTP Method using "x-http-method-override" header parameter here is the sample code for that

    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....