function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Read XML using HttpRequest is not working

Unable to fetch the data.

public class AccountUpdater {

  //Future annotation to mark the method as async.
  public static void updateAccount(String id, String name) {

    //construct an HTTP request
    HttpRequest req = new HttpRequest();

    //send the request
    Http http = new Http();
    HttpResponse res = http.send(req);

    //check the response
    if (res.getStatusCode() == 200) {

      //update account
      Account acc = new Account(Id=id);
      acc.Description = res.getBody();
      update acc;
    } else {
      System.debug('Callout failed: ' + res);

 Description is blank. I have used trigger to call this class. and also have added the URL in Remote site. I have checked  Apex Job,it shows job status Completed. I am trying from developer account

Best Answer chosen by Admin (Salesforce Developers) 



First of all you have to check in debug window what you are getting the account id for update the records.


                //check the response

                if (res.getStatusCode() == 200)


                                system.debug( ' Account ID'  +  id);

                                Account acc = new Account(Id=id);

                                acc.Description = res.getBody();

                                update acc;



Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.