Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. private HttpClient client = new HttpClient();
  2.  
  3. public void patch(...) throws Exception {
  4. PostMethod patch = createPost(instanceUrl + "/services/data/"
  5. + API_VERSION + "/sobjects/" + sobType + "/"
  6. + sobIdMap.get(oldSobId) + "?_HttpMethod=PATCH"
  7. );
  8. patch.setRequestEntity(new StringRequestEntity(update.toString(), "application/json",
  9. "UTF-8"));
  10. client.executeMethod(patch);
  11. if (patch.getStatusCode() == ...) {
  12. ...
  13. } else {
  14. ...
  15. }
  16. }
  17.  
  18. private PostMethod createPost(String uri) {
  19. PostMethod post = new PostMethod(uri);
  20. post.setRequestHeader("Authorization", "OAuth " + sessionId);
  21. return post;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement