How to use EDI API as ASP .NET Core

Article author
  • Updated

InHouse EDI API allows you to run EdiNation's EDI translation and validation API in your own cloud or on-prem environment(s).

This tutorial uses the example ASP .NET Core solution that comes with the EdiNation Inhouse product.

InHouse API for ASP .NET Core on GitHub



To complete this tutorial, you'll need the following:

  • Visual Studio 2022, which supports .NET 6.0. 
  • Download Postman - it's an application to consume/test your API.
  • EDI test file(s) - the API supports X12, EDIFACT, EANCOM, HL7, NCPDP, VDA, and EDIGAS. If you don't have a test file, use one of ours - X12 HIPAA, X12, EDIFACT.


Debug the ASP .NET application in Visual Studio

EdiFabric.Api.dll only works with the edition of EdiFabric.dll included in the solution. Do not install EdiFabric separately from NuGet!

  1. Download EdiNation Inhouse, unzip it, and navigate to folder edifabric-api-aspnet.
  2. Open solution EdiFabric.Api.ASPNET.sln in Visual Studio 2022.
  3. Open the file appsettings.json and change ApiKey to the API key you received when subscribing to EdiNation InHouse (the existing one is for the free EdiNation plan).


  4. Ensure the references to EdiFabric.dll and EdiFabric.Api.dll exist.
  5. Rebuild the solution and ensure all package dependencies were installed correctly.


  6. Run the EdiFabric.Api.ASPNET project in debug mode.


Test the ASP .NET application

  1. Download and open Postman. Let's test the X12 read operation first.
  2. Open a new tab in Postman, select the POST method, and add the following request URL (full API reference):

    {Your ASP.NET application URL}/x12/read
  3. Go to the Body tab, select the "binary" content, and then browse to your text X12/HIPAA file.

    If you don't have a test file, use one of ours - X12 HIPAA, X12, EDIFACT.


  4. Finally, hit the Send button and inspect the response body:




If you receive an error message that begins with any of the below, then your API key wasn't correctly configured or has expired, or you've reached a quota limit:

  • One or more errors occurred. (Can't get token!)
  • Transaction set is not supported


Implement distributed cache

For every request to your API, at least two requests are initiated to the cloud EdiNation API - one to acquire a token and another to get the model for your transaction type (if your file contains transactions of different types, such as invoices and purchase orders, then there will be a separate request for each type).

To avoid making these requests, you can implement a distributed cache that can share tokens and models across function invocations. This example uses a simple folder and file as a distributed cache.

Token cache

To implement the token cache, follow these steps:

  1. (Optional) Open the file TokenFileCache.cs and change the _tokenFile to the path you want. By default, a file named token.txt will be dropped in the current directory.


  2. Open the controller file for the EDI standard you will be using, e.g., for X12, open the file X12Controller.cs; for EDIFACT, open the file EdifactController.cs, etc., and uncomment all lines that begin with:

  3. In the same file(s), comment out all lines that begin with:

    // SerialKey.Set
  4. Done! The next time you execute a Lambda function, the token will be loaded from the cache.

Models cache

Let's assume you will be working with files containing X12 transactions of version 4010. By default, every time you execute an operation of the InHouse API, the model for standard X12 and version 4010 is retrieved from the EdiNation API like this:


Using a cache will load all models from the cache instead of the EdiNation API.

To implement the models' cache, follow these steps:

  1. Go to EdiNation Formats and select the model you will be loading to the cache (in this example, X12 4010).


  2. Download the model as a .dll file.


  3. The file on your disk must be EdiNation.X12.ASC.004010.dll.
  4. Go to folder edifabric-api-aspnet\EdiFabric.Api.ASPNET and create a new subfolder named EDI.
  5. Copy the file EdiNation.X12.ASC.004010.dll to folder edifabric-api-aspnet\EdiFabric.Api.ASPNET\EDI.


  6. Open the file LocalModelsService.cs and ensure the path to the EDI folder is correct:


  7. Open the file Program.cs and uncomment all lines that begin with:

  8. Done! The next time you execute a call to read an X12 4010 file, the models will be loaded from the cache.


Configure CORS

When you use the in-house edition of EDI Translator, you need to configure CORS in the ASP.NET Core application by following these steps.


Next steps

Learn about the in-house edition of EDI API.

Learn about how to use Inhouse EDI API as AWS Lambda

Learn about how to use InHouse EDI API as Azure Function


Share this:

Was this article helpful?



Please sign in to leave a comment.