1

I am trying to upgrade my c# programs to VersionOne.SDK.API version 15.3.0.0. I am getting a message that VersionOneAPIConnector is obsolete and that I should use V1Connector instead. When the ObjectModel API was discontinued, I had changed to doing everything with VersionOneAPIConnector using query.v1 (using HttpPost) and rest-1.v1/Data(using SendData). After getting the new version, I figured out how to use V1Connector and pass it to Services and then to use ExecutePassThroughQuery() to pass what had been the 2nd argument to HttpPost for my query.v1 code like this:

Original code:

        Stream resultStream = _cx.HttpPost("/query.v1", System.Text.Encoding.UTF8.GetBytes(GetQueryForMembers()));
        using (StreamReader reader = new StreamReader(resultStream, Encoding.UTF8))
        {
            result = reader.ReadToEnd();
        }

New Code:

        result = _service.ExecutePassThroughQuery(GetQueryForMembers());

Where GetQueryforMembers() is:

    public static string GetQueryForMembers()
    {
        return @"
            from: Member
            select:
              - Email
            where:
              AssetState: Active";

    }

But, I can't figure out how to use V1Connector/IServices for my rest/SendData code. All the Rest examples on the VersionOne site now show using it from the API Console, not from stand-alone code. It looks like at least some of the things I was doing with Rest can be done via Services.executeOperation() or Services.Meta, but the V1 employee that I was working with to get rid of my Object Model code a few years ago had recommended only using the API for the connection and to otherwise use Rest and Query, so that I didn't have to worry about compatibility with .NET versions. But, from looking at the examples currently provided and the functionality available on the V1Connector/IServices classes, it looks like maybe V1 wants us to use Meta API rather than REST now? Or is there a way to use REST directly that I am missing? From looking at the source, I see there is an internal UseDataAPI() on the V1Connector that IServices uses. But, it only uses it in Save, ExecuteOperation and Retrieve and it doesn't look like any of those do what I'm trying to do.

This is an example, if what I was doing before with REST (where _passed_cx is a VersionOneAPIConnector)

string newDefect = string.Concat("<Asset href=\"/MentorG01/rest-1.v1/New/Defect\">",
                            "<Attribute name=\"Name\" act=\"set\">", cdata_attribute_value, "</Attribute>",
                             "<Relation name=\"Scope\" act=\"set\">",
                               "<Asset href=\"/MentorG01/rest-1.v1/Data/Scope/", project_oid.Split(':')[1], "\" idref=\"", project_oid, "\" />",
                              "</Relation>",
                            "</Asset>");

        string url = "rest-1.v1/Data/Defect";

        Stream resultStream = _passed_cx.SendData(url, newDefect);

Anyone know how to use rest-1.v1 with V1Connector? If so, can you provide an example?

0 Answers0