You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Click the top button "Generate DueDil V4 API client"
From the dropdown menu select you desired language/platform, for this tutorial "C# .NET 2" and download the ZIP package
Preparing the client DLL
This is for Mac/Linux users only
Extract the archive with the generated client
Compile the client code
/bin/bash compile-mono.sh
The client should be located under bin/IO.Swagger.dll
Create new C# project and import client
Open VisualStudio and create new MVC project
In the root of the project create new folder "libs/"
Copy the DLL file of the Swagger client there
From the top menu select "Project > Edit Preferences > .Net Assembly (tab)"
Browse and add the Swagger client to the build of the project "./libs/IO.Swagger.dll"
From the top menu select "Project > Add NuGet Packages ... > Search for "RestSharp.Net2" and install"
Build the project
Updating the code to work with the API
usingSystem;usingSystem.Collections.Generic;usingSystem.Diagnostics;usingSystem.Linq;usingSystem.Threading.Tasks;usingMicrosoft.AspNetCore.Mvc;usingDuedilApi.Models;usingIO.Swagger.Api;usingIO.Swagger.Client;usingIO.Swagger.Model;namespaceDuedilApi.Controllers{publicclassHomeController:Controller{conststringRESPONSE_FORMAT="json";conststringAPI_AUTH_TOKEN="<YOUR_API_KEY_HERE>";conststringDEFAULT_COMPANY_ID="06999618";privateIEssentialsApiessentialsApi;publicHomeController(){Configuration.ApiKey["X-AUTH-TOKEN"]=API_AUTH_TOKEN;essentialsApi=newEssentialsApi();}publicIActionResultIndex(StringCompanyId){try{stringcompanyId=CompanyId==null?DEFAULT_COMPANY_ID:CompanyId;Debug.WriteLine(CompanyId);Debug.WriteLine(companyId);// Company vitalsCompanyResponseresult=essentialsApi.CompanyCountryCodeCompanyIdFormatGet("gb",companyId,RESPONSE_FORMAT);ViewData["companyId"]=result.CompanyId;ViewData["countryCode"]=result.CountryCode;ViewData["name"]=result.Name;ViewData["status"]=result.SimplifiedStatus;ViewData["address"]=result.RegisteredAddress.FullAddress;Debug.WriteLine(result);}catch(Exceptione){Debug.Print("Exception when calling EssentialsApi.CompanyCountryCodeCompanyIdFormatGet: "+e.Message);}returnView();}publicIActionResultError(){returnView(newErrorViewModel{RequestId=Activity.Current?.Id??HttpContext.TraceIdentifier});}}}
About
This is demo integration of the API V4 Client in C# .NET 2 application