Execute MQL API
MQL
MQL is Mingle's SQL-like query language. Execute MQL API allows you to use MQL queries via the API.
We recommend that you familiarize yourself with some MQL before using it via the API.
Structure of the Execute MQL result resource
Unlike other APIs the structure of what is returned in a result resource will differ depending on the MQL that is specified in the request. In general the structure will reflect the properties that were requested in the MQL. For example, if you select for number and name, the results returned will have the attributes number and name.
Results will be returned in XML format by default. However, Mingle can also return the result in JSON or JSONP format.
Unless otherwise specified the following examples show the results in XML format.
Using Execute MQL to get a specific set of properties for a specific set cards
Reference
Request Method: GET
URL: /api/v2/projects/project_identifier/cards/execute_mql.xml
mql: MQL select statement. String.
Example
GET
http://localhost:8080/api/v2/projects/new/cards/execute_mql.xml
mql=SELECT number, name WHERE 'Iteration - Scheduled' = (Current Iteration)
Explanation
The above is an example of a GET request to retrieve a specific set of card where "'Iteration - Scheduled' = (Current Iteration)" from the project with identifier "new". This will return the number and name of cards that match the MQL conditions supplied.
Result
If you were authorized to perform the operation, and the operation succeeded, you will be returned an array of results resources.
<?xml version="1.0" encoding="UTF-8"?>
<results type="array">
<result>
<number>77</number>
<name>Whitespace created when just checking properties</name>
</result>
<result>
<number>74</number>
<name>File audit results beginning to outgrow the audit control and cut off text.</name>
</result>
...
</results>
Using Execute MQL to get the results of a value query
Reference
Request Method: GET
URL: /api/v2/projects/project_identifier/cards/execute_mql.xml
mql: MQL select statement. String.
Example
GET
http://localhost:8080/api/v2/projects/new/cards/execute_mql.xml
mql=SELECT COUNT(*) WHERE Type = story
Explanation
The above is an example of a GET request to retrieve a specific value from the project with identifier "new". This will return a count of cards that match the MQL conditions supplied.
Result
If you were authorized to perform the operation, and the operation succeeded, you will be returned a results resource.
<?xml version="1.0" encoding="UTF-8"?>
<results type="array">
<result>
<count>64</count>
</result>
</results>
How to return a result in JSON format
Reference
URL: /api/v2/projects/project_identifier/cards/execute_mql.json
mql: SELECT number, name WHERE type = Story
Explanation
The above is an example of a GET request to retrieve a specific set of cards where type is 'Story'. This will return the number and name of any cards of type 'Story' in JSON format.
How to return a result in JSONP format
Reference
URL: /api/v2/projects/project_identifier/cards/execute_mql.json
callback: displayCards
mql: SELECT number, name WHERE type = Story
Explanation
The above is an example of a GET request to retrieve a specific set of cards where type is 'Story'. This will return the number and name of any cards of type 'Story' in JSON format. Mingle will prefix this result with the callback function which you have provided.