Answered question

How do you use the Data Exchange API Clinet without getting errors on the NewClient method

I've got a simple Visual Studio program which references the NeotysRestDataExchangeAPI. I have successfully built the solution which uses the NewClient and TimerBuilder.Start/Stop.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Neotys.DataExchangeAPI.Model;
using Neotys.DataExchangeAPI.Client;

namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
IDataExchangeAPIClient client = DataExchangeAPIClientFactory.NewClient("http://IBA-SP4-RK:7400/DataExchange/v1/Service.svc/"...;);
// IDataExchangeAPIClient client = DataExchangeAPIClientFactory.NewClient("http://IBA-SP4-RK:7400/DataExchange/v1/Service.svc/";);

for (int i = 0; i < 10; i++)
{
TimerBuilder timer1 = TimerBuilder.Start("Script1", "Timer1");
System.Threading.Thread.Sleep(1000);
client.AddEntry(timer1.Stop());
}
}
}
}

However when I run the .exe from with NeoLoad using the End User Experience Action I get the following Error. I have tried it with both the API Key set and not set within the REST API Project settings.

==== ERR ====

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'Simple.OData.Client.Net40, Version=4.16.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
at Neotys.DataExchangeAPI.Client.DataExchangeAPIClientOlingo..ctor(String url, Context context, String apiKey)
at Neotys.DataExchangeAPI.Client.DataExchangeAPIClientFactory.NewClient(String url)
at ConsoleApp1.Program.Main(String[] args) in C:\Users\RajKumar\source\repos\ConsoleApp1\ConsoleApp1\Program.cs:line 19

Alexis N.
Alexis N.

Alexis N.

Level
2
805 / 2000
points
Team

I reproduce your issue, you need to provide a context when creating the client.

ContextBuilder cb = new ContextBuilder();
cb.Hardware = "test";

IDataExchangeAPIClient client = DataExchangeAPIClientFactory.NewClient("http://IBA-SP4-RK.home:7400/DataExchange/v1/Service.svc/&...;, cb.build());

This issue will be fixed in next version.

Did you find this useful ?

No (0)

Yes (1)

100%

100% of users found this answer useful

Other answers

Alexis N.
Alexis N.

Alexis N.

Level
2
805 / 2000
points
Team

It look's like a dependency issue. What is your .NET version?
How are you referencing the Neotys API dependencies? With NuGet?

Alexis,
Thanks for answering.
The .Net version is 4.7.0305. I'm running VS version 15.7.4.

I added the reference to to the API from NeoLoad
as follows.
Are you say there are dependencies to this?
C:\Program Files\NeoLoad 6.5\api\Data Exchange API Client\Csharp\NeotysRestDataExchangeAPI.dll

Alexis N.
Alexis N.

Alexis N.

Level
2
805 / 2000
points
Team

Yes are also dependencies to NeotysRestDataExchangeAPI.dll, located in C:\Program Files\NeoLoad 6.5\api\Common\Csharp.

Alexis,
I added NeotysRestCommonAPI.dll to the reference. Also I noted that I should've targeted
http://IBA-SP4-RK.home:7400/DataExchange/v1/Service.svc/
and not
http://IBA-SP4-RK:7400/DataExchange/v1/Service.svc/

The error that I'm getting now is

==== ERR ====

Unhandled Exception: Neotys.DataExchangeAPI.Error.NeotysAPIException: NL-API-ERROR
at Neotys.DataExchangeAPI.Client.NeotysAPIClientOlingo.WriteEntity(IEdmModel edm, String url, String entitySetName, IDictionary`2 data)
at Neotys.DataExchangeAPI.Client.NeotysAPIClientOlingo.ReadEntity(String entitySetName, IDictionary`2 properties)
at Neotys.DataExchangeAPI.Client.DataExchangeAPIClientOlingo..ctor(String url, Context context, String apiKey)
at Neotys.DataExchangeAPI.Client.DataExchangeAPIClientFactory.NewClient(String url, String apiKey)
at ConsoleApp1.Program.Main(String[] args) in C:\Users\RajKumar\source\repos\ConsoleApp1\ConsoleApp1\Program.cs:line 22