Task 2 – Get Projects
By the end of this task, you will be able to:
- Fetch project information like project ID and name of the project.
- Make sense of the options and fields in the documentation on the projects query, Projects object, and Project object.
You will use the following queries in this task:
Step 1: Request for a list of Projects within a Hub
The projects query returns a Projects object. The Projects object contains an array of Project objects. In this exercise, we query for the project id
and project name
fields.
- In the AEC Data Model Explorer, the query is populated by default in the Query Pane. You can also edit or update the query as per your requirement and run it.
Query
query GetProjects($hubId: ID!) { projects(hubId: $hubId) { pagination { cursor } results { id name alternativeIdentifiers{ dataManagementAPIProjectId } } } }
Show More- In the Query Variables Pane, enter the value of the
hubId
obtained from Get Hubs topic.Query Variables
{ "hubId": "urn:adsk.ace:prod.scope:dccde3e3-c20c-40d3-a27c-7ac53b051b6e" }
- Click Play. The list of projects available within that hub is displayed in the response. Note down the ExternalIDs and Project IDs of one of the projects. You will need these IDs for the remaining tasks. In this tutorial, we will use the ID of the project named “AEC Data Model API Private Beta”. The response should be similar to the following code-block:
Response
{ "data": { "projects": { "pagination": { "cursor": null }, "results": [ { "id": "urn:adsk.workspace:prod.project:39208068-e548-4d9e-b8a7-e000fdf2a9b4", "name": "AEC DM Bootcamp Project", "alternativeIdentifiers": { "dataManagementAPIProjectId": "b.ddcecd34-68b7-41af-ad65-2ce571186c6c" } } ] } } }
Show More
After working through the steps mentioned above, you should see a screen similar to the following image: