Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

I am calling below webservice when i update the record in account object, trigger calling the webservice but when i used below webservice i am getting 503 error i am follwing the below link http://cheenath.com/?tutorial/sfdc/sample1/index.html it is working fine for me, when i change the url at that time i am getting 503 error what is the problem

public class AccountUpdater {


  @Future(callout=true)
  public static void updateAccount(String id, String name) {

    //construct an HTTP request
    HttpRequest req = new HttpRequest();
    req.setEndpoint('http://justsee.corp.aaaa.net/endpointurl.txt');
    req.setMethod('GET');

    //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);
    } 
  }
}
share|improve this question
add comment

1 Answer 1

The HTTP status numbers have specific meanings. For example your 503 means:

The Web server (running the Web site) is currently unable to handle the HTTP request due to a temporary overloading or maintenance of the server. The implication is that this is a temporary condition which will be alleviated after some delay.

That suggests the problem is not at your end of the communication but at the other server end.

As this is a simple unauthenticated GET, you can just enter the URL in your browser and check the result you get there compared to the result you get in your Apex code. (Right now http://justsee.corp.aaaa.net/ does not appear to exist.)

Also note that you have to allow your org to access to the remote server via Setup -> Security -> Remote Site Settings.

share|improve this answer
    
Actually i changed the URL my orginal url is justice4.corp.aitcc.net/endpointurl.txt –  Sathya Mar 22 at 12:06
    
I just pasted that into my browser's URL and it doesn't exist either. Get the code working with a URL you know exists. –  Keith C Mar 22 at 12:07
    
it asking me an user name and password..i used the above URL which is asking UserName and Pwd.. –  Sathya Mar 22 at 12:26
    
OK, though I'm not sure why I can't see the site at all. Again having proven the process using your browser (i.e. making sure you have a valid username and password for the site), you can then add the authentication information to your request. This is how to do it for one type of username/password prompt salesforce.stackexchange.com/questions/11015/…, but the site you are trying to connect to may be using some other protocol. Best to check the site's documentation. –  Keith C Mar 22 at 12:35
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.