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
Reddy@SFDCReddy@SFDC 

send error messages

Hi all, please help me.....i want to throw http error messages in this code with the status code.....

 

 

global class InboundLinxUserRegistration {
      global class dtRegistrationInput {
      webservice ID UserId;
      webservice String First_Name;
      webservice String Last_Name;
      webservice String Email_Address;
      webservice String Status;
      webservice ID Workplace_Id;
      webservice String Workplace_Name;
      webservice String Workplace_Province;
      webservice String Workplace_City;
      webservice String Workplace_Postal_Code;
      webservice String Workplace_Address;
      webservice String Speciality;
      webservice String Record_Type;
        }
     global class dtRegistrationOutput {
       webservice String status;
       webservice String Message_Text;
      }
     
      public webservice static dtRegistrationOutput userregistration(dtRegistrationInput userregistration){
           dtRegistrationOutput retvalue=new dtRegistrationOutput();
           retvalue.status='Success';
                          
            Account account=new Account();
                             
                     account.National_Code__c=userregistration.UserId;
                     account.FirstName=userregistration.First_Name;
                     account.LastName=userregistration.Last_Name;
                     account.PersonEmail=userregistration.Email_Address;
                     account.Account_Status_NES__c=userregistration.Status;
                     account.Primary_Parent_vod__c=userregistration.Workplace_Id;
                     account.Primary_Province_NES__c=userregistration.Workplace_Province;
                     account.Primary_City_NES__c=userregistration.Workplace_City;
                     account.Primary_Postal_Code_NES__c=userregistration.Workplace_Postal_Code;
                     account.Primary_Address_1_NES__c=userregistration.Workplace_Address;
                     account.Specialty_1_vod__c=userregistration.Speciality;
                     account.RecordTypeId=userregistration.Record_Type;
                     try{
                          insert account;
                         } catch (Exception e){
                            retvalue.Status='Failure';
                            retvalue.Message_text=e.getMessage();
                           
                           }
                  
          return retvalue;
       }
  }

Best Answer chosen by Admin (Salesforce Developers) 
kiranmutturukiranmutturu

may be this will be useful to you

 

HttpResponse res = http.send(req);

System.debug('STATUS:'+res.getStatus());

System.debug('STATUS_CODE:'+res.getStatusCode());

All Answers

kiranmutturukiranmutturu

may be this will be useful to you

 

HttpResponse res = http.send(req);

System.debug('STATUS:'+res.getStatus());

System.debug('STATUS_CODE:'+res.getStatusCode());

This was selected as the best answer
Reddy@SFDCReddy@SFDC

what is req