Question

I'm getting a warning while building my asp.net project that V1APIConnector is deprecated and requesting me to use VersionOneAPIConnector.

Using the new VersionOneAPIConnector I had to do the following to get a child projects:

  1. build a string (ex: https://abc.org/V1/rest-1.v1/Data/Scope?where=Scope.Name='FOO'&sel=Children.Name) for the data we require and then pass it on to GetData method.
  2. read the returned stream and then create an xml.
  3. Read the xml to extract the required data.

Retrieving data using V1APIconnector was much simpler.

  1. create a IMetaModel and services instance
  2. query the appropriate assettype (GetAssetType method) and the attributes (getAttributedefinition)

Is the above approach still valid using VersionOneAPIConnector?
If yes do we have any example on how to get the childprojects of a project?

Thanks

Was it helpful?

Solution

The compilation warnings that you are getting are because VersionOne.SDK.APIClient is currently using internally V1APIconnector, and this warnings are only shown because, I guess, you are including VersionOne.SDK.APIClient inside your project, this approach is, sometimes, not advisable because you may miss updates. The best thing to do should be to use nuget. Add to VS a reference (Tools -> Options -> Packate Manager -> Package Sources) to V1 gallery on myget.org (https://www.myget.org/F/versionone/), in this way you'll have your DLLs updated.

Regarding your questions: There's no need for you to directly use VersionOneAPIConnector, but here you have two examples of listing child projects: one using Metamodel as you mention that you were using, and another using VersionOneAPIConnector.

//Example 1: Listing all child projects of 'Foo' with MetaModel

var assetType = _context.MetaModel.GetAssetType("Scope");
var query = new Query(assetType);
//Filter Attribute
var parentNameAttribute = assetType.GetAttributeDefinition("Parent.Name");
//Filter
var filter = new FilterTerm(parentNameAttribute);
filter.Equal("Foo");
query.Filter = filter; 
var result = _context.Services.Retrieve(query);

Example 2: Listing all child projects of 'Foo' with VersionOneAPIConnector and V1 user and password.

Stream streamResult = new VersionOneAPIConnector("https://abc.org/v1sdktesting/rest-1.v1/Data/Scope?where=Parent.Name=%27Foo%27").WithVersionOneUsernameAndPassword("usr","pwd").GetData();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top