Sample project for a new API connection in C#

Modifié le  Thu, 16 Sep 2021 sur 08:26 AM

This document will guide you through the steps to create a new API connection from scratch.

Requirements for this sample project are:

  • .Net Framework 3.0 or higher
  • Visual Studio 2013 or higher
  • A valid API key

To get a detailed overview of a SOAP compliant webservice, you can simply open the endpoint in a web browser.

For example, if you open you get the following page:

There are multiple ways to connect with this API, but we will focus on the most accessible way for developers and technical profiles. 

1. Open Visual Studio and create a new project

2. Select "Console App (.NET Framework)"

3. Once the project is created, right click "References" and select "Add Service Reference.."

4. In the "Add Service Reference" screen, fill in the endpoint URI you would like to use and select "Go" 

5. Open the file App.config and verify which bindingConfiguration values have been added.

  • In this example, both ArchiveSoap (SOAP standard 1.1) and ArchiveSoap12 (SOAP standard 1.2) are valid configuration names.

6. Open the file Program.cs and include the following namespace:

using ConsoleApp1.ServiceReference1; // this is <projectname>.<chosen namespace>
Insert the following code in Main:

var client = new ArchiveSoapClient("ArchiveSoap");            // this is a binding config
var sessionID = client.Authenticate("xxx-xxx-xxx-xxx-xxx");   // insert API key here
var response = client.GetCurrentDomain(sessionID);            // example call to the API

Congratulations, you now have a working example to connect to!
The same approach can be used to target any SOAP compliant webservice provided by Yuki.

Cet article a-t-il été utile ?

C'est super !

Merci pour votre commentaire

Désolé ! Nous n'avons pas pu vous être utile

Merci pour votre commentaire

Dites-nous comment nous pouvons améliorer cet article !

Sélectionner au moins l'une des raisons

Commentaires envoyés

Nous apprécions vos efforts et nous allons corriger l'article