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
EQ AdminEQ Admin 

I am new to integration. I am writing a REST webservice which will accept dates as BODY and use those dates in SOQL to extract the records. I am not able to get the dates in in my Webservice from body. Below is my code:

I am new to integration. I am writing a REST webservice which will accept dates as BODY  and use those dates in SOQL to extract the records. I am not able to get the dates in in my Webservice from body. Below is my code: 

/*

 */
@RestResource(urlMapping='/WorkdayIntegration/') 
global class APTS_InvoiceDetailsWS
{
    
@HttpPost
    global static List<APTS_WorkdayIntegrationWrapper> getInvoiceDetails()
    { 
        //Fetch an account
        RestRequest req = RestContext.request;
        String jsonBody = req.requestBody.toString(); //the body of the request
        
        
        RestResponse res = RestContext.response;
         
      List<Apttus_Billing__Invoice__c> invoiceObjectList=new List<Apttus_Billing__Invoice__c>(
          [Select id,Name,EQ_InvoiceApprovedDate__c,Apttus_billing__status__c,CurrencyIsoCode,Apttus_Billing__ShipToAccountId__r.EQ_ClientRef__c,Apttus_Billing__ShipToAccountId__r.EQ_ShippingState__c,
           Apttus_Billing__InvoiceDate__c,EQ_DueDateCustom__c,EQ_TotalTaxAmount__c
           from Apttus_Billing__Invoice__c where /*EQ_InvoiceApprovedDate__c>=:startDate and EQ_InvoiceApprovedDate__c <=: endDate */
            EQ_TotalInvoiceAmount__c > 0  and Apttus_billing__status__c= 'Approved'  limit 4]);
        
      List<APTS_WorkdayIntegrationWrapper> lstInvoiceHistory = new List<APTS_WorkdayIntegrationWrapper>(); 
      for(Apttus_Billing__Invoice__c invoice:invoiceObjectList)
              {
                APTS_WorkdayIntegrationWrapper invoiceWrapper=new APTS_WorkdayIntegrationWrapper();
                invoiceWrapper.InvoiceName=invoice.Name;
                invoiceWrapper.CountryISOCode=invoice.CurrencyIsoCode;
                invoiceWrapper.InvoiceId=invoice.id;
                invoiceWrapper.ClientReference=invoice.Apttus_Billing__ShipToAccountId__r.EQ_ClientRef__c;
                invoiceWrapper.ShippState=invoice.Apttus_Billing__ShipToAccountId__r.EQ_ShippingState__c;
                invoiceWrapper.InvoiceDate=invoice.Apttus_Billing__InvoiceDate__c;
                invoiceWrapper.InvoiceAmount= invoice.EQ_TotalTaxAmount__c;
                invoiceWrapper.InvoiceSourceSystem='APTTUS';
    invoiceWrapper.ExternalCompanyId='APTTUS';
    invoiceWrapper.FromDate= '2019-08-01';
    invoiceWrapper.ToDate= '2019-08-03';
    invoiceWrapper.TotalNumberOfInvoices= 109;
            lstInvoiceHistory.add(invoiceWrapper);
            JSON.serialize(lstInvoiceHistory);
                  
              }
        
        
        return lstInvoiceHistory;
    }
    
    
    global class APTS_WorkdayIntegrationWrapper
    {
      public String InvoiceName;
        public string InvoiceSourceSystem;
        public string ExternalCompanyId;
    public string FromDate;
    public string  ToDate;
    public decimal TotalNumberOfInvoices;
        
        public String InvoiceId;
        public String CountryISOCode;
        public String ClientReference;
        public String ShippState;
        public dateTime InvoiceDate;
        public Decimal InvoiceAmount;
        public date InvoiceDueDate;
    } 
    
}