1

I am running into a problem with the VersionOneAPIClient in that it will not recognize anything I give it ass an asset type. I understand the Attribute definitions probably don't make any sense but I've been trying pretty much everything. My end goal would be to query TeamRooms and get team names from all the teams in the team room.

It's my understanding from the documentation on asset types and how to query that this should work but that's what we all say.

I am using: C# ASP.NET, VersionOneAPIClient 15.0.0.0

Strings I have tried:

  • TeamRoom
  • Task
  • Scope
  • Project

        public bool APIgetTeams()
    {
        IAssetType teamroomType = services.Meta.GetAssetType("Task");
        Query query = new Query(teamroomType);
        IAttributeDefinition teamAttribute = teamroomType.GetAttributeDefinition("Children:Room.Team.Name");
        query.Selection.Add(teamAttribute);
        IAttributeDefinition scheduleAttribute = teamroomType.GetAttributeDefinition("Children:Scope.Room.Schedule.Name");
        query.Selection.Add(scheduleAttribute);
        query.Find = new QueryFind(scheduleName, new AttributeSelection(scheduleAttribute));
        query.Paging.PageSize = 1;
        query.Paging.PageSize = 0;
        teamRoomAsset = (Asset)services.Retrieve(query).Assets.ToArray().GetValue(0);
    
        return true;
    }  
    

My definition of services and the connector:

        public static V1Connector connector = V1Connector
           .WithInstanceUrl("http://versionone.cscinfo.com/VersionOneProd/")
           .WithUserAgentHeader("New Dashboard?", "1.0")
           .WithWindowsIntegrated()
           .Build();
    public IServices services = new Services(connector);

And these are my Errors / Stack Traces: Error Server Error Meta Stack Trace

The error is likely simple and right in my face but I can't figure it out.

Griffin
  • 242
  • 4
  • 20

1 Answers1

5

You have a couple of things going on here. I will address your statement "My end goal would be to query TeamRooms and get team names from all the teams in the team room."

Here is a working chunk of code that reads all of your TeamRooms and prints the name of the Team Room and the Team Name. Once you get this working on your machine, attempt to do the paging. Add filtering incrementally to keep the debug cycles low.

 static void Main(string[] args)
    {

        V1Connector connector = V1Connector
            .WithInstanceUrl("https://www.MyV1INstance")
            .WithUserAgentHeader("HappyApp", "0.1")
            .WithUsernameAndPassword("login", "pwd")
            .Build();


        IServices services = new Services(connector);

        IAssetType trType = services.Meta.GetAssetType("TeamRoom");
        Query query = new Query(trType);
        IAttributeDefinition teamAttribute = trType.GetAttributeDefinition("Team.Name");
        IAttributeDefinition nameAttribute = trType.GetAttributeDefinition("Name");
        query.Selection.Add(teamAttribute);
        query.Selection.Add(nameAttribute);


        QueryResult result = services.Retrieve(query);
        Asset teamRooms = result.Assets[0];

        foreach (Asset story in result.Assets)
        {
            Console.WriteLine(story.Oid.Token);
            Console.WriteLine(story.GetAttribute(teamAttribute).Value);
            Console.WriteLine(story.GetAttribute(nameAttribute).Value);
            Console.WriteLine();
        }

Addendum

I just realized that you were using WithWindowsIntegrated() instead of WithUsernameAndPassword().

Just change that in my sample but then confirm that you are logged into the machine as a Member that is already setup in VersionOne. The windows int auth is trusting IIS' decision to trust you but then immediately after allowing auth, you have to have an active Member account in VersionOne to have access to VersionOne assets.

Mark Irvin
  • 830
  • 1
  • 6
  • 16
  • 1
    You will never understand how grateful I am for your guidance. – Griffin Jun 11 '15 at 20:38
  • Found the problem. I was making the connector static so then it could be passed the the service and by doing so it broke everything. I should of seen this. – Griffin Jun 12 '15 at 12:26
  • I'm having the same issue in Java, and I'm wondering why the connector being static would matter, as I also abstracted it away into a separate static utility class. Could you clarify? – Bill Horvath Jul 16 '15 at 17:38