Get Projects
Key learnings
By the end of this task, you will be able to:
- Define query variables in the Manufacturing Data Model Explorer.
- Send a query that requires an argument.
- Fetch project information like project repository, associated root folder ID, and count of objects in the root folder of the project.
- Make sense of the options and fields in the documentation on the projects query, Projects object, and Project object.
Queries used in this task
You will use the following queries in this task:
Type | Operation | Description |
---|---|---|
Query | projects | Retrieves all projects within a specified hub. |
Step 1 - Request for a list of Projects within a Hub
The projects query returns a Projects object which contains an array of Project objects.
For this exercise, we request the id
field and the name
fields of each project, as well as the id
, name
, and objectCount
fields of the rootFolder
for each project.
- In the Manufacturing Data Model Explorer, enter the following query in the Query Pane :
Query
query GetProjects($hubId: String!) {
projects(hubId: $hubId) {
results {
id
name
rootFolder {
id
name
objectCount
}
}
}
}
Show More
- In the Query Variables Pane, take note of the ID of the hub you got in Get Hubs. Then, simply copy and paste that ID as the value for the
hubId
in the Query variable Pane.
Query Variables
{ "hubId" : "a.YnVzaW5lc3M6YXV0b2Rlc2s2MTA0" }
- Click Play. The response will show a list of projects available in the hub. Make sure to write down the IDs of a project and its root folder. These IDs will be required for the remaining tasks. As an example, let’s use the IDs of the project named
Default Project
and its root folder to continue. The response will resemble the following code-block:
Response
{ "data": { "projects": { "results": [ { "id": "a.YnVzaW5lc3M6YXV0b2Rlc2s2MTA0IzIwMjIwNjAzNTMwNjM5NDgx", "name": "Test", "rootFolder": { "id": "urn:adsk.wipprod:fs.folder:co.E3mp-ZuRScapqZi7Ek6ygw", "name": "Test", "objectCount": 0 } }, { "id": "a.YnVzaW5lc3M6YXV0b2Rlc2s2MTA0I0QyMDIyMDIwMjQ5MjcyNTIzMQ", "name": "Default Project", "rootFolder": { "id": "urn:adsk.wipprod:fs.folder:co.X97YjKyaStKU9UnADkhk-w", "name": "Default Project", "objectCount": 29 } }, { "id": "a.YnVzaW5lc3M6YXV0b2Rlc2s2MTA0I0QyMDIyMDIwMjQ5MjcyOTcwNg", "name": "Assets", "rootFolder": { "id": "urn:adsk.wipprod:fs.folder:co.NvQSo2ZdRza0CzpwBpTUag", "name": "Assets", "objectCount": 6 } } ] } }
Show More
After working through the steps mentioned above, you should see a screen similar to the following image.