Search code examples
versionone

V1APIConnector returning 0 results for any query


I am using the V1APIConnector to connect to my VersionOne application. For any query I execute, I always get 0 records in the results. Below is part of the code I am using:

V1APIConnector dataConnector = new V1APIConnector( _dataUrl, _username, _password);
V1APIConnector metaConnector = new V1APIConnector( _metaUrl );
IMetaModel metaModel = new MetaModel(metaConnector);
IServices services = new Services(metaModel, dataConnector);
System.out.println("Creating query");
IAssetType defectType = metaModel.getAssetType("Defect");
Query query = new Query(defectType);
IAttributeDefinition nameAttribute = defectType.getAttributeDefinition("Name");
query.getSelection().add(nameAttribute);
query.getPaging().setPageSize(3);
query.getPaging().setStart(0);
System.out.println("Retrieve from query");
QueryResult result = services.retrieve(query);
System.out.println("Result Size:" + result.getAssets().length);

There are thousands of defects in my V1 application. Even if I query for a particular user , Member:1000, I get 0 resords, even if the member is present. Is there is thing in the code which is not correct?

Thanks for your help, R.


Solution

  • Not seeing any issues with your code, it should execute fine.

    A few things that you could check:

    1. Make sure that your URLs are correct and follow these patterns:

      data: http://{server}/{instance}/rest-1.v1/Data/
      meta: http://{server}/{instance}/meta.v1/

    2. Check that the member account that you are using has the right level of permissions, and that it has been assigned to the project that you want to query against. Assuming that you want all defects in the system, the project will be System (All Projects) which has the OID of Scope:0.