Creating an Object and Defining Fields
Scenarios
You can create a VehicleType object and define fields to store vehicle types and type IDs.
The following describes how to call the APIs for creating an object and defining fields. For details, see Calling APIs.
Creating an Object
- Determine the request based on the actual request URI and method.
POST https://Huawei Cloud Astro Zero domain name/u-route/baas/metadata/v1.0/object
- Set the request header.
Table 1 Request header Header Field
Description
Mandatory
Content-Type
Parameter defined in the HTTP protocol, which identifies the format for parsing the returned content. This parameter must be set to application/json, indicating that the browser parses the returned content into a JSON object.
Yes
access-token
When a user login request is authenticated, the backend generates a token, which is contained in the response and saved in the browser. When the user sends a request to Astro Zero, the token will be carried, indicating that the user has been authenticated.
Yes
- Construct the message body.
{ "label": "VehicleType", "name": "VehicleType__CST", "description": "", "fields": [ { "label": "Name", "name": "name", "dataType": "Name" } ], "view": { "ObjectDetailLayout": { "name": "__layout__VehicleType__CST__detail", "fields": [ "name" ] }, "ObjectRecordsLayout": { "name": "__layout__VehicleType__CST__records", "fields": [ "name" ] } } }
If the following response is returned, the object is created. Record the value cust000000aHYAsrPh4K of result, which is the object ID.
{ "resCode": "0", "resMsg": "Success", "result": "cust000000aHYAsrPh4K" }
Defining Fields
- Determine the request based on the actual request URI and method. cust000000aHYAsrPh4K is the object ID.
POST https://Huawei Cloud Astro Zero domain name/u-route/baas/metadata/v1.0/object/cust000000aHYAsrPh4K/fields
- Set the request header.
Table 2 Request header Header Field
Description
Mandatory
Content-Type
Parameter defined in the HTTP protocol, which identifies the format for parsing the returned content. This parameter must be set to application/json, indicating that the browser parses the returned content into a JSON object.
Yes
access-token
When a user login request is authenticated, the backend generates a token, which is contained in the response and saved in the browser. When the user sends a request to Astro Zero, the token will be carried, indicating that the user has been authenticated.
Yes
- Construct the request body that carries the VehicleType and VehicleNumber fields.
{ "fields": [ { "label": "VehicleType", "name": "VehicleType__CST", "dataType": "text", "dataLength": 255, "caseSensitive": false, "isRequired": false, "isUnique": false, "isSearchable": false }, { "label": "VehicleNumber", "name": "VehicleNumber__CST", "dataType": "text", "dataLength": 255, "caseSensitive": true, "isRequired": false, "isUnique": true, "isSearchable": false } ] }
If the following response is returned, the fields are created:
{ "resCode": "0", "resMsg": "Success", "result": [ "cust000000aHaE6S3mim", "cust000000aHaE6TlNVA" ] }
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot