Error during API call ARCustomers

SOLVED

Hello Team,

When I try to call ARCustomers via API using a filter that designated in the Sage 300 specification, I received an error.

Example of the request:
http://{IP Adress}/Sage300WebApi/v1.0/-/SAMLTD/AR/ARCustomers?$filter=DateLastMaintained le datetime'2021-05-31T12:00'

Response:
{
"error": {
"code": "InvalidParameters",
"message": {
"lang": "en-US",
"value": "Unrecognized 'Edm.String' literal 'datetime'2021-05-31T12:00'' at '22' in 'DateLastMaintained le datetime'2021-05-31T12:00''."
}
}
}


What I should change in the request to eliminate the error?

Parents
  • +1
    verified answer

    Here is how I did it

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

    What this does is created a date string in yyyy-MM-dd format. It's how the string is required when using the web API.

Reply
  • +1
    verified answer

    Here is how I did it

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

    What this does is created a date string in yyyy-MM-dd format. It's how the string is required when using the web API.

Children