Skip to main content

Notifications

Announcements

No record found.

Business Central forum
Answered

Web Services(ODataV4) filter on BC

Posted on by 3,957
Hi All,
I've created custom Sales Header Page and Sales Line Page to extract data using Web Services in ODataV4.
I want to apply filters I tried applying filters as follows
1. api.businesscentral.dynamics.com/.../Company('CRONUS%20USA%2C%20Inc.')/DWSalesOrderLinesAPI?$count=true&$filter=Shipment_Date%20gt%202018-01-01T23:59:59.999Z
giving error: 'Unable to convert value to Date'
2. api.businesscentral.dynamics.com/.../Company('CRONUS%20USA%2C%20Inc.')/DWSalesOrderLinesAPI?$count=true&$filter=Shipment_Date%20eq%20'2018-09-19'
giving error: A binary operator with incompatible types was detected. Found operand types 'Edm.Date' and 'Edm.String' for operator kind 'Equal'
I've refered here:
I'm wondering if these filters are available for Web Services or API in BC?
And also what exactly is the difference between API and WebService(ODataV4) as I've found few differences like Parent-Child relationship and complex data types.
Kindy advise!
Categories:
  • Verified answer
    Olister Rumao Profile Picture
    Olister Rumao 3,957 on at
    RE: Web Services(ODataV4) filter on BC

    Hi Stefano,

    I could get the filtered results with query as below

    https://api.businesscentral.dynamics.com/v1.0/:tenant/ODataV4/Company('CRONUS%20USA%2C%20Inc.')/DWSalesOrderLinesAPI?$count=true&$filter=Shipment_Date%20ge%202018-05-01 

    Also, I found that the filter is specific to the data type of the field

    For example:

    Date = 2018-09-09

    DateTime = 2018-09-19T20:05:52.667Z

    Integer = 1

    Decimal = 1.00

    Text = ‘Text’

    Code = ‘PS’

    Options = ‘Order’/’Quote’

    Boolean = true/false

    I'll try the query as you provided and give the feedback thanks.


  • Suggested answer
    Stefano Demiliani Profile Picture
    Stefano Demiliani 37,154 on at
    RE: Web Services(ODataV4) filter on BC

    The datetime filter is wrong.

    You should write something like:

    Shipment_Date ge datetime'2018-01-01T00:00:00Z'

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 288,459 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,783 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans