polarion

How to use queries ('queryWorkItems', 'queryWorkItemsBySQL', etc.) via Polarion API


I am using SOAP API to communicate with Polarion server. In one of WSDL files, there are defined a few webservices to query work items, but I could not find a single example how to use them. Let say that I want to ask the server for all work items that are 'Test Case' type in project 'My First Project'. What parameter values should I pass to 'queryWorkItems' or 'queryWorkItemsBySQL'?

I have found following documentation with structure of the requests: https://almdemo.polarion.com/polarion/sdk/doc/javadoc/com/polarion/alm/ws/client/tracker/TrackerWebService.html#queryWorkItems(java.lang.String,java.lang.String,java.lang.String%5B%5D) https://almdemo.polarion.com/polarion/sdk/doc/javadoc/com/polarion/alm/ws/client/tracker/TrackerWebService.html#queryWorkItemsBySQL(java.lang.String,java.lang.String%5B%5D)

Unfortunately I have no idea what 'query' or 'sqlQuery' should be like.. Could you provide any examples?


Solution

  • I have found how to build and send API requests with Lucene queries. In this video, there is shown how to build (in video since 0:40) and convert them in text format (in video since 2:52): https://www.youtube.com/watch?v=DSRKfdr2aJc

    Once you have txt query in Lucene format build, you send API webservice request:

    queryWorkItems(query, sort, fields)
    

    Example (Python syntax):

    queryWorkItems(query="project.id:MyProject AND type:testcase", sort="uri", fields=["id", "assignee"])
    

    Dictionary of [Work Item field] -> [field type]:

    FIELDS = {
            "approvals": "ArrayOfApproval",
            "assignee": "ArrayOfUser",
            "attachments": "ArrayOfAttachment",
            "author": "User",
            "categories": "ArrayOfCategory",
            "comments": "ArrayOfComment",
            "created": "dateTime",
            "description": "Text",
            "dueDate": "date",
            "externallyLinkedWorkItems": "ArrayOfExternallyLinkedWorkItem",
            "hyperlinks": "ArrayOfHyperlink",
            "id": "string",
            "initialEstimate": "duration",
            "linkedOslcResources": "ArrayOfLinkedOslcResource",
            "linkedRevisions": "ArrayOfRevision",
            "linkedRevisionsDerived": "ArrayOfRevision",
            "linkedWorkItems": "ArrayOfLinkedWorkItem",
            "linkedWorkItemsDerived": "ArrayOfLinkedWorkItem",
            "location": "Location",
            "moduleURI": "SubterraURI",
            "outlineNumber": "string",
            "plannedEnd": "dateTime",
            "plannedIn": "ArrayOfPlan",
            "plannedStart": "dateTime",
            "planningConstraints": "ArrayOfPlanningConstraint",
            "previousStatus": "EnumOptionId",
            "priority": "PriorityOptionId",
            "project": "Project",
            "remainingEstimate": "duration",
            "resolution": "EnumOptionId",
            "resolvedOn": "dateTime",
            "severity": "EnumOptionId",
            "status": "EnumOptionId",
            "timePoint": "TimePoint",
            "timeSpent": "duration",
            "title": "string",
            "type": "EnumOptionId",
            "updated": "dateTime",
            "workRecords": "ArrayOfWorkRecord",
            "customFields": "ArrayOfCustom",
            "uri": "SubterraURI",
            "unresolvable": "boolean",
        }