Showing posts with label API. Show all posts
Showing posts with label API. Show all posts

Thursday, February 22, 2024

Filter by Date Range with Business Central Web API v2.0 - OData date filter syntax

by Steve Endow

I just spent 10 minutes trying to figure out the proper syntax for date filtering with Business Central Web API v2.0 endpoints, so I am documenting it here for future reference.

I don't regularly work with BC Web APIs these days, so when I have to dig back into them every 3-6 months, I'm almost always rusty and have a hard time remembering the URL format and the OData filter syntax used by Business Central Web APIs.

Today I was trying to filter the results returned from the generalLedgerEntries endpoint.  If I try to call that endpoint without a filter, Postman gives me an error because it is returning too much data.

The body of this response was too large to be saved

Fine, let's filter based on postingDate.  But I don't remember the OData filter syntax.  Unfortunately, the OData documentation has ZERO examples of filtering by date.

Friday, March 4, 2022

Business Central Web API Error When Using $expand

 By Steve Endow

I recently responded to a Business Central Community Forum post here:

https://community.dynamics.com/business/f/dynamics-365-business-central-forum/448915/api-query-with-odata-date-filter-with-encoding

While researching that question, I learned something from that forum post:  $expand=*

Huh, I didn't know that was possible!

If you aren't familiar with the $expand OData query option, check out my blog post on the topic:

https://blog.steveendow.com/2021/09/using-metadata-and-expand-with-business.html

So it seems that you can use a wildcard with $expand to automatically expand all Navigation Properties available in a Business Central Web API endpoint. Very interesting!

I personally don't think I would ever recommend using such a query option in a real world API integration, but I was intrigued by the possibility!

So I fired up Postman and did some testing with my new found query option.

Query Option $expand=*

Friday, November 26, 2021

Business Central API - Filter Child Array Values Using $filter Query Option

 by Steve Endow

I had a difficult time finding an example of this type of API filtering using the OData $filter query option, so I wanted to share an example that I needed for a project.

For context, this is a very simple example of a Business Central API "child array" that I wanted to filter.  Technically, I think that OData calls this an "expanded navigation property".

Customers with Expanded contactsInformation Navigation Property


First, if you are not familiar with the OData $metadata URL and the $expand query parameter, please see my blog post here.

How many digits can a Business Central Amount field actually support?

 by Steve Endow (If anyone has a technical explanation for the discrepancy between the Docs and the BC behavior, let me know!) On Sunday nig...