Monday, June 16, 2025

Using .http file for testing D365 FinOps APIs

 

Introduction:

This document provides a comprehensive, step-by-step guide on how to create and utilize a .http file for testing out-of-the-box (OOTB) APIs available in Microsoft Dynamics 365 Finance and Operations (D365 FnO). The .http file format, supported in modern IDEs such as Visual Studio Code, offers a simple and efficient way to compose, send, and validate HTTP requests directly from your development environment. By leveraging this approach, developers can streamline the API testing process, enhance productivity, and reduce dependency on external tools like Postman or SOAP UI. This guide covers the fundamentals of setting up your environment, configuring authentication, defining request bodies, and interpreting responses to effectively interact with D365 FnO APIs.

 

Prerequisites:

Steps for testing FnO APIs:

1)Project configurations:

a.      Create a new project with the template ASP.NET Core Empty

A screenshot of a computer

AI-generated content may be incorrect.

                                                 

 

b.      In Configuration of project name the project and define the location of the project and click ‘Next

A screenshot of a computer

AI-generated content may be incorrect.

                                                          

 

c.       Setup Additional information by selecting the .Net framework and mark ‘Configure for HTTPS’. Uncheck ‘Enable container support’.

A screenshot of a computer

AI-generated content may be incorrect.

                                                                  

 


2) Setting up .env file for environment variables:

a.      Right click on the project and click on ‘New Item’

 

b.      Name the file exactly as ‘http-client.env.json’. Locate the file in the same directory as the .http file or in one of its parent directories.

A computer screen shot of a computer screen

AI-generated content may be incorrect.

                                                                   

 

c.       Here is an example of an environment file:

A screenshot of a computer

AI-generated content may be incorrect.

 

3)      3)Create and configure .http file for API testing:

a.      Right click on the project and click on ‘New Item’

A screenshot of a computer

AI-generated content may be incorrect.

                                                   

b.      One this compact view window of ‘Add New Item’ pops up, click on ‘Show All Templates

A screenshot of a computer

AI-generated content may be incorrect.

                                c.       Go to ‘ASP.NET Core’ section and find the item ‘HTTP File’. Name the file with .http extension and click on ‘Add  

A screenshot of a computer

AI-generated content may be incorrect.
d.      Once .http file is created in the project, the blank will look as follows   
A screenshot of a computer

AI-generated content may be incorrect.


e.      On the right – top corner you can see the env dropdown which enlists the environment configuration defined in Section 2.

A screenshot of a computer

AI-generated content may be incorrect.

                                                             

f.        Add the below configuration to setup an endpoint to get the Token through OAuth from the token authentication URL, while utilizing the environment variables defined in the .env file. Once done click on ‘Send request’ to send the request to the endpoint URL and you can generate the response on the right hand side of the window as shown below

                                


                                                       

g.       You can setup the custom service or any other OOB FnO endpoint using the below configuration. While utilizing the token value retrieved from the response under attribute ‘access_token’.      



 

Reference : Use .http files in Visual Studio 2022

Using .http file for testing D365 FinOps APIs

  Introduction : This document provides a comprehensive, step-by-step guide on how to create and utilize a .http file for testing out-of-t...