79676091

Date: 2025-06-23 11:37:34
Score: 0.5
Natty:
Report link

I was facing the same issue with my Java application. The API worked just fine in Postman, but had the "PATCH method not allowed" exception when called through the Springboot application. I used this code to access this. FYI, I also tried adding ?_HttpMethod=PATCH for the post method, but had no luck.

String url = UriComponentsBuilder.newInstance()
  .scheme(protocol)
  .host("your-salesforce-instance-url")
  .path(apiVersionPath + "/sobjects/Case/" + caseId)
  .toUriString();

PostMethod postMethod = new PostMethod(url) {
  @Override
  public String getName() {
    return "PATCH";
  }
};

postMethod.setRequestHeader(HttpHeaders.AUTHORIZATION, "Bearer xxxxxx");
ObjectMapper mapper = new ObjectMapper();
String body = mapper.writeValueAsString("your-json-request");
postMethod.setRequestEntity(new StringRequestEntity(body, ContentType.APPLICATION_JSON, "UTF-8"));
HttpClient httpClient = new HttpClient();
int statusCode = httpClient.executeMethod(postMethod);
Reasons:
  • Blacklisted phrase (1): no luck
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Akhilesh Magdum