Search code examples
axaptadynamics-365-operationsdynamics-ax7

Get Dynamics 365 Finance & Operations data entity via HTTP GET as CSV output


Given a Finance & Operations environment, the environmentdomain.com/data/EntityName URL allows OData data retrieval in JSON format.

Is there a way to give extra query string parameters to download the results as CSV using HTTP GET only?

A workaround is described here, however it has more overhead for ad hoc situations.


Solution

  • Unfortunately, the supported features from the OData specification for the D365FO OData requests do not support the system query option $format.

    So no, as far as I can tell, there is no query string parameter that would return the HTTP GET request response in csv format.

    Additional workarounds

    Since the questions mentions a workaround that has some overhead for ad hoc situations, here are two more suggestions how the response can be changed to CSV format with less overhead.

    Postman

    Postman is often used for ad hoc testing of the D365FO OData API. Convert a JSON reponse to CSV describes how a Javascript test can be added to a Postman request to convert the JSON response to CSV format and write it to the console.

    PowerShell

    The Invoke-RestMethod cmdlet can be used to send HTTP GET requests to the D365FO API. The result can then be used with the Export-Csv cmdlet to create a CSV file.

    I strongly recommend you use the d365fo.integrations PowerShell module written by @splaxi specifically to interact with the D365FO OData API instead of Invoke-RestMethod. The Get-D365ODataEntityData can be used to send an HTTP GET request.