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
Swamy P R NSwamy P R N 

Getting error from Google Advanced Rest API Client :503 service unavailable

Hi Guys,

Am posting json text data from google advanced rest api client,but it throws error like :503 Service Unavailable

It is the Data am giving : {"rewardamnt"="15000","active_or_inactive": "true"}

Content-Type :application/json

MY URL : --> site URL

WebMethods-->Site Name

services/apexrest-->Common for apex rest resource

RewardCreation--->My controller having urlmapping.

Hi Swamy, 

503 Service Unavailable
Types of service issues are listed below. Be sure to check the X-Google-Command header to determine whether a retry is allowed.
Server error
Service unavailable
Insufficient quota

If the upload operation is interrupted or gets an HTTP 503 or 500 response, you should query for the number of bytes it has received by implementing another PUT Object request. The PUT Object request must have the following:

An empty entity body.
A Content-Length request header, which must be set to 0.
A Content-Range request header, which specifies the byte range you are seeking status for.
An upload_id query string parameter, which specifies the upload ID for the resumable upload.

503 – Service Unavailable All Events The end-point is unable to handle the API call. For example, there is scheduled downtime for the end-point back-end systems. The Push API will retry three times, and then suspend the call.

See the examples in the doc,

Reply back if you have further questions.


Swamy P R NSwamy P R N
HI Ashish,

yaa my issue is resolved ,some days back.Mainly its because of  removing WebMethods value from the URI .

Now am able to send the request,but i am not getting any response in my system.
Actually am trying with salesforce - salesforce integration using Rest Resource. See below one,
Here is my code : Sending Data to Extrnal sys

webService static void callExternalsysAndUpdatereward(string body){
        Http h = new Http();
         HttpRequest req = new HttpRequest();
            system.debug('Reward Data '+body);   
           // Send the request, and return a response
         HttpResponse res = h.send(req);
         system.debug('HttpResponse res '+res.getbody());

in other system its invoking  properly .Class :

global class cls_RecieveAndSend_DatatoSrisys

    global static MyUserDefinedClass doPost()
        RestRequest req = RestContext.request;
        System.debug('req  Body '+req);
        RestResponse res = RestContext.response;
        string strJSON = req.requestBody.toString();
           System.debug('Json O/P is '+strJSON);
        JSONparser parser = JSON.createParser(strJSON);    
        Type reqObj = Type.forName('cls_ReceivingSupport');       
        cls_ReceivingSupport rewCls=(cls_ReceivingSupport)parser.readValueAs(reqObj);
        MyUserDefinedClass My=new MyUserDefinedClass();
        if(rewCls.month==null && rewCls.year!=null && rewCls.empid!=null){
            User u = [select id,name from user where Emp_Id__c=:rewCls.empid];
            System.Debug('Users Name :'+u.Name);
            Reward__c r = [select id,name,Time_Based_Mgmnt__c,Cut_off_Percent__c,Active__c,Rward_Amount__c,User__c from Reward__c where (( AND (CALENDAR_YEAR(Time_Based_Mgmnt__r.Start_Date__c)=:rewCls.year))];
           JSONGenerator gen = JSON.createGenerator(true);
                  gen.writeNumberField('Reward Amount',r.Rward_Amount__c);
                  gen.writeStringField('Period Data',r.Time_Based_Mgmnt__c);
                  gen.writeStringField('User Data',r.User__c);
                String jsonString = gen.getAsString();
                System.Debug('Json O/P is '+jsonString);
                My.Data='Rewards List is '+jsonString;
        System.Debug('Json O/P My '+My);
      return My;
    global class MyUserDefinedClass {     
        global String Data;      
        //global String Amount;
        global string Status;

sending is success to another system,that system is invoking properly but am not able to get the response in first system. can you suggest me on this.
Hi , 

Are you getting any errors? Can you share the debug logs to see if we can fund any clue where it is breaking. 

See the below link for similar information,


Swamy P R NSwamy P R N

Am getting response..its good but i want to show it in VF Page.But i was not able to show because its showing error .I know the error because of static method iam not able to call any other things in inside of this method.
but how can i achieve this?
Hi Swamy, 

Hope this helps,

Important Considerations
When using the webservice keyword, keep the following considerations in mind:
You can use the webservice modifier to define top-level, outer class methods and variables, and member variables of an inner class. It can't be used on a class itself, or an interface or interface methods or variables.
An Apex trigger can execute a callout when the callout is invoked within a method defined as asynchronous: that is, defined with the @future keyword. The @future annotation signifies that the Apex method executes asynchronously. For more information on the @future annotation, please read the documentation.
All classes that contain methods or variables defined with the webservice keyword must be declared as global. If a method, variable or inner class is declared as global, the outer, top-level class must also be defined as global.
You must define any method that uses the webservice keyword as static.
Because there are no SOAP analogs for certain Apex elements, methods defined with the webservice keyword cannot take the following elements as parameters. While these elements can be used within the method, they cannot be used as return values.
Pattern objects
Matcher objects
Exception objects
You must use the webservice keyword with any member variables that you want to expose as part of a web service. You should not mark these member variables as static. Please see this section for more information.

The following section illustrates how to expose member variables and inner Apex classes to be accessed by external applications. In more detail, by exposing the member variables and inner Apex Classes with the webservice modifier, those attributes will be included in the custom Apex WSDL created by this Web service-enabled Apex Class. Therefore, the external application that imports the WSDL has access to operate against those members or objects as it would any other data type or object.
global class AccountPlan {
   webservice String area;
   webservice String region;
   //Define an object in apex that is exposed in apex web service
   global class Plan {
      webservice String name;
      webservice Integer planNumber;
      webservice Date planningPeriod;
      webservice Id planId;

   webservice static Plan createAccountPlan(Plan vPlan) {
       //A plan maps to the Account object in
       //So need to map the Plan class object to Account standard object
       Account acct = new Account();
       acct.Name =;
       acct.AccountNumber = String.valueOf(vPlan.planNumber);
       insert acct;
       return vPlan;

Else, reply back with the exact error message so that we can get the right documentation. 


Ramesh Naidu PRamesh Naidu P
how to resolve erron 503 in salesforce API?
Ramesh Naidu PRamesh Naidu P
how to resolve error 503 in salesforce API
Swamy P R NSwamy P R N
Hello Ramesh Naidu,

I got this error 1.5yrs back but still remembered the error. I got the error because of Site Name in the URI. I didn't provide the site name in URL Mapping url. So try to check the site name which you have given in the URI, Also give public access to that site.
Ramesh Naidu PRamesh Naidu P
but its  not working from today only.
Amine HAmine H
I resolved this issue by implementing the retry logic in my ETL job
here is the desc
Satish PrajapatSatish Prajapat
Hello All,
please refer the below code:
​HttpRequest req = new HttpRequest();
req.setEndpoint('Your url which you want to hit.');
req.setBody('Body');//When I added this tag than I removed the 'read time out error.'
HttpResponse response = new Http().send(req);
Enjoy my Dost...!!!!
karimulla testingkarimulla testing
hi sSwamy PRN,, 

  Http http = new Http();
                     HttpRequest request = new HttpRequest();
        HttpResponse response = http.send(request);
        // Parse the JSON response
        if (response.getStatusCode() != 404) {
            System.debug('The status code returned was not expected: ' +
                response.getStatusCode() + ' ' + response.getStatus());
        } else {
... Actually we are trying to restcallout form salesforce application to other dotnet(.net) application which is in developing in local server or hosted in the local server  ... iam getting an  error as shownUser-added image
how to make the callout will the other application is in localserver...any idea will be appreciated....