Skip to navigation

Task 2 - Create a Company

View as Markdown

A company typically represents a real-world company. It is a container of all the namespaces and schemas of that company. So, in this step you create company to hold all the schemas you will create for this tutorial.

You do not need any special privileges to create a company. Every company you create is private by default. You will have admin privileges to the company and all namespaces and schemas within that company.

Expected task outcome

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

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

Endpoints used in this task

You will use the following API endpoints in this task:

MethodEndpointOperation
POST/companiesCreate a Company
GET/companies/{companyId}Fetch a Company

Step 1 - Create a Company

In Postman, on the sidebar, Select Task 2 > POST Create a Company and click Send. The equivalent cURL request is as follows.

Request

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

|

A script in the Tests tab saves the ID of the company to a variable named COMPANY_ID, so that it can be used in subsequent API calls.

Response

{
"data": {
"type": "companies",
"id": "<COMPANY_ID>",
"attributes": {
"name": "<COMPANY_NAME>",
"title": "<COMPANY_TITLE>",
"description": "<COMPANY_DESCRIPTION>",
"createdBy": "vRx4GPkPtgn6UwldLHddl1XoPxPNgm25",
"createTime": "2022-06-20T02:49:58Z",
"lastModifiedBy": "vRx4GPkPtgn6UwldLHddl1XoPxPNgm25",
"lastModifiedTime": "2022-06-20T02:49:58Z"
}
}
}

Step 2 - Fetch Company

This topic explains how to fetch the details of a specific company and the permission you have been granted.

In postman, Select Task 1 > GET Fetch Company 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>' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer <YOUR_ACCERSS_TOKEN>'

|

Response

{
"data": {
"type": "companies",
"id": "<COMPANY_ID>",
"attributes": {
"name": "<COMPANY_NAME>",
"title": "<COMPANY_TITLE>",
"description": "<COMPANY_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-20T02:49:59Z",
"lastModifiedBy": "vRx4GPkPtgn6UwldLHddl1XoPxPNgm25",
"lastModifiedTime": "2022-06-20T02:49:59Z"
}
}
}