Skip to navigation

Task 3 - Create a Namespace

View as Markdown

A namespace is a group of schemas. Namespaces insulate the schema in your namespace from the schema in other namespaces. Even if another namespace has a schema with the same name as your schema, it would not matter. This is because the Forge Schema service factors in the namespace in the unique ID it assigns to your schema.

Every namespace is private by default. The creator of the namespace has read, write, and delete access to the namespace.

Expected task outcome

By the end of this task you will be able to:

  • Create a new namespace.
  • Fetch details of namespace.

Endpoints used in this task

You will use the following API endpoints in this task:

MethodEndpointOperation
POST/companies/{companyId}/namespacesCreate a Namespace
GET/companies/{companyId}/namespaces/{namespaceId}Fetch a Namespace

Step 1 - Create a Namespace

In postman, Select Task 2 > POST Create a Namespace and click Send. The equivalent cURL request is as follows.

Request

curl -X POST \
'https://developer-stg.api.autodesk.com/schema/v2/companies/<COMPNAY_ID>/namespaces' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer <YOUR_ACCERSS_TOKEN>' \
-d '{
"type": "namespaces",
"attributes": {,
"name": "<NAMESPACE_NAME>",
"title": "<NAMESPACE_TITLE>",
"description": "<NAMESPACE_DESCRIPTION>"
}
}'

In Postman, a script in the Tests tab saves the ID of the namespace to a variable named NAMESPACE_ID, so that it can be used in subsequent API calls.

|

Response

{
"data": {
"type": "namespaces",
"id": "<NAMESPACE_ID",
"attributes": {
"name": "<NAMESPACE_NAME>",
"title": "<NAMESPACE_TITLE>",
"description": "<NAMESPACE_DESCRIPTION>",
"createdBy": "vRx4GPkPtgn6UwldLHddl1XoPxPNgm25",
"createTime": "2022-06-20T03:36:28Z",
"lastModifiedBy": "vRx4GPkPtgn6UwldLHddl1XoPxPNgm25",
"lastModifiedTime": "2022-06-20T03:36:28Z"
}
}
}

Step 2 - Fetch Namespace

In Postman, Select Task 2 > GET Fetch a Namespace and click Send. The equivalent cURL request is as follows.

Request

curl -X GET \
'https://developer-stg.api.autodesk.com/schema/v2/companies/<COMPANY_ID/namespaces/<NAMESPACE_ID>' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer <YOUR_ACCERSS_TOKEN>'

|

Response

{
"data": {
"type": "namespaces",
"id": "NAMESPACE_ID",
"attributes": {
"name": "NAMESPACE_NAME",
"title": "NAMESPACE_TITLE",
"description": "NAMESPACE_DESCRIPTION",
"permissions": [
{
"Id": "read",
"Effect": "Allow",
"Subjects": {
"Service": [
"vRx4GPkPtgn6UwldLHddl1XoPxPNgm25"
]
},
"Action": "read"
},
{
"Id": "admin",
"Effect": "Allow",
"Subjects": {
"Service": [
"vRx4GPkPtgn6UwldLHddl1XoPxPNgm25"
]
},
"Action": "admin"
},
{
"Id": "delete",
"Effect": "Allow",
"Subjects": {
"Service": [
"vRx4GPkPtgn6UwldLHddl1XoPxPNgm25"
]
},
"Action": "delete"
},
{
"Id": "write",
"Effect": "Allow",
"Subjects": {
"Service": [
"vRx4GPkPtgn6UwldLHddl1XoPxPNgm25"
]
},
"Action": "write"
}
],
"createdBy": "vRx4GPkPtgn6UwldLHddl1XoPxPNgm25",
"createTime": "2022-06-20T03:36:28Z",
"lastModifiedBy": "vRx4GPkPtgn6UwldLHddl1XoPxPNgm25",
"lastModifiedTime": "2022-06-20T03:36:28Z"
}
}
}