Error during the search Customers by period via API

SUGGESTED

Hello Team,

Could you help me with the following question.

I cannot filter Customers by date and time.

Example:
http://{BASE_URL}/Sage300WebApi/v1.0/-/SAMLTD/AR/ARCustomers?$top=1000&$filter=DateLastMaintained gt 2000-01-01T01:08:35 or DateOfLastActivity gt 2000-01-01T01:08:35

Response:
 400 Bad Request: [{
  “error”: {
    “code”: “InvalidParameters”,
    “message”: {
      “lang”: “en-US”,
      “value”: “The DateTimeOffset text ‘2000-01-01T01:08:35’ should be in format ’yyyy-mm-ddThh:mm:ss(’.’s+)?(zzzzzz)?' and each field value is within valid range.”
    }
  }
}]

Could you help me with how I should change a request to eliminate the error?

  • 0
    SUGGESTED

    Date formats are done this way:

    string sDateXDaysAgo = DateTime.Now.AddDays(-cMConfig.CMLimitGetBalancesToXPreviousDays).ToString("yyyy-MM-dd");
    sFilter = "?%24filter=DateOfLastActivity%20ge%20" + sDateXDaysAgo + "%20or%20DateLastMaintained%20ge%20" + sDateXDaysAgo + "&%24select=CustomerNumber%2CTerms%2CCreditLimitCustomerCurrency%2CBalanceDueInCustomerCurrency%2CBalanceDueInFunctionalCurrency";
    

    You format your dates this way: DateTime.Now.ToString("yyyy-MM-dd")