Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Answered

Proper way to use filters with business central API in On-Prem multitenant environment.

Posted on by 25

Greetings to Everyone.

I am having trouble figuring out the proper usage of filter with OnPrem Business Central Api. We have used multi-tenant deployment.

This is working
http://localhost:7048/gasorgn/api/BizNP/biobizapi/v1.0/companies(3530cd87-f0b2-ec11-9111-82e8be684e31)/generalledgerentries?tenant=gasmaster

But while using the filter this way, it is not working
http://localhost:7048/gasorgn/api/BizNP/biobizapi/v1.0/companies(3530cd87-f0b2-ec11-9111-82e8be684e31)/generalledgerentries?$filter=PostingDate eq 2022-03-15?tenant=gasmaster

Likewise, use of expand on standard api also does not work
http://localhost:7048/gasorgn/api/v2.0/companies(3530cd87-f0b2-ec11-9111-82e8be684e31)/customers?$expand=contactsInformation?tenant=gasmaster

They Give the following message

{"error":{"code":"Authentication_InvalidCredentials","message":"Web service call failed because user could not be authenticated or authorized. CorrelationId: ae68c640-ec54-43f2-90b9-27c80fdb1f45."}}


I would be grateful for any help or suggestions.

  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 73,565 Super User 2024 Season 2 on at
    RE: Proper way to use filters with business central API in On-Prem multitenant environment.

    Hi, I used to sort out the Filters method in APIs.
    Hope the below will help you too.

    More details: https://yzhums.com/6117/

    Operator Description Example
    Comparison operators    
    eq  Equal ?$filter=category eq 'Expense'
    ne  Not equal ?$filter=unitPrice ne 0
    gt Greater than ?$filter=unitPrice gt 1000
    ge Greater than or equal ?$filter=unitPrice ge 1000
    lt Less than ?$filter=unitPrice lt 1000
    le Less than or equal ?$filter=unitPrice le 1000
    Logical operators    
    and Logical and ?$filter=number ge '50000' and number lt '60000'
    or Logical or ?$filter=category eq 'Expense' or category eq 'Income'
    not Logical negation Not supported
    Grouping    
    () Precendence grouping ?$filter=(category eq 'Expense' or category eq 'Income') and (number ge '40000' and number lt '50000')
    Comparison operators    
    contains Search for substring ?$filter=contains(displayName, 'red')
    endswith Test if first string ends with second string ?$filter=endswith(email,'contoso.com')
    startswith Test if first string starts with second string ?$filter=startswith(email,'aj')
    concat Returns a string that appends the second paramter to the first Not supported
  • Verified answer
    Roshan Dangol Profile Picture
    Roshan Dangol 25 on at
    RE: Proper way to use filters with business central API in On-Prem multitenant environment.

    After some research I found out the correct to embed both filter and tenant both at once to API url is through & operator instead of ? operator that I used in my question. So, the correct url would be:

    http://localhost:7048/gasorgn/api/BizNP/biobizapi/v1.0/companies(3530cd87-f0b2-ec11-9111-82e8be684e31)/generalledgerentries?$filter=PostingDate eq 2022-03-15&tenant=gasmaster

  • Suggested answer
    Andy Sather Profile Picture
    Andy Sather on at
    RE: Proper way to use filters with business central API in On-Prem multitenant environment.

    Hello,

    If you don't get further responses to this issue, you may want to raise a support request to Microsoft support via your CSP / Partner.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans