0

Hi I try to update an existing record using REST callout.

String uri = 'https://test--dev.my.salesforce.com/services/data/v25.0/sobjects/Account/' + ACCId;

HttpRequest reqUpd = new HttpRequest();
reqUpd.setEndpoint(uri);
reqUpd.setMethod('PATCH');
reqUpd.setHeader( 'Content-Type', 'application/json' );
reqUpd.setHeader( 'Authorization', 'Bearer ' + token );
reqUpd.setBody(JSON.serialize(
        new Map<String, String> { 'Custom_field' => 'false'}));
reqUpd.setTimeout(120000);
HttpResponse httpRes = http.send(reqUpd);

In result, i get empty body

1 Answer 1

4

PATCH requests to the sObject Rows REST resources are documented to return no body:

Example response body for updating fields in an Account object
    none returned

You should be looking at the result status code for a 200-series HTTP status to determine the outcome of your call.

Additionally, you should not write new code against the ancient API version 25.0. By doing so, you are opting in to literally years' worth of now-fixed bugs and obsolete behaviors. Always write new code against recent API versions (52.0 as of this writing).

4
  • 1
    Not to mention, everything south of v30.0 (<=29.0) is being disabled/deprecated next year (2022).
    – sfdcfox
    Jul 18, 2021 at 23:26
  • @sfdcfox Thanks for the answer. But what do I need to replace since I get a 204 error again. I need update Custom_field Jul 19, 2021 at 4:52
  • @David Reed Thanks for the answer. But what do I need to replace since I get a 204 error again. I need update Custom_field Jul 19, 2021 at 4:52
  • 2
    @sartynallid any result from 200-299 is not an error, it is a success message, in this case a 204 No Content message. The system is telling you that the update completed successfully without error and no data was returned (which is normal for an update call).
    – sfdcfox
    Jul 19, 2021 at 4:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .