Create object
1 min
POST
https://api.us1.odp.optimizely.com/v3/schema/objects
Body Parameters
- bodyObjectrequiredExamplesExample Payload:
{ "name": "objects", "display_name": "Object", "public_read": false, "alias": "object", "fields": [ { "name": "object_id", "display_name": "New Object Identifier", "public_read": false, "type": "string", "primary": true }, { "name": "another_field", "display_name": "Another Fields", "type": "string" }, { "name": "child_id", "display_name": "Child Identifier", "type": "number" } ], "relations": [ { "name": "my_relation", "display_name": "My Relationship", "public_read": false, "child_object": "child", "join_fields": [ { "parent": "child_id", "child": "child_id" } ] } ] }- namestringrequiredDescription
- display_namestringrequiredDescription
- public_readbooleanrequiredDescriptionDefaultfalse
- aliasstringrequiredDescription
- fieldsobject[]requiredDescription
- namestringExample
- display_namestringExample
- typestringExample
- primarybooleanExampleDefaulttrue
- relationsobject[]Description
- namestringExample
- display_namestringExample
- child_objectstringExample
- join_fieldsobject[]
- parentstringExample
- childstringExample
Responses
200
- ObjectExample
{ "name": "objects", "display_name": "Object", "alias": "object", "fields": [ { "name": "object_id", "display_name": "New Object Identifier", "type": "string", "primary": true }, { "name": "another_field", "display_name": "Another Fields", "type": "string" }, { "name": "child_id", "display_name": "Child Identifier", "type": "number" } ], "relations": [ { "name": "my_relation", "display_name": "My Relationship", "child_object": "child", "join_fields": [ { "parent": "child_id", "child": "child_id" } ] } ] }- namestringrequiredDescription
- display_namestringrequiredDescription
- public_readbooleanrequiredDescriptionDefaultfalse
- aliasstringrequiredDescription
- fieldsobject[]requiredDescription
- namestringExample
- display_namestringExample
- typestringExample
- primarybooleanExampleDefaulttrue
- relationsobject[]Description
- namestringExample
- display_namestringExample
- child_objectstringExample
- join_fieldsobject[]
- parentstringExample
- childstringExample
400
- ErrorExample
{ "title": "Bad Request", "status": 400, "timestamp": "2018-08-07T13:44:17.659Z", "detail": { "invalids": [ { "field": "name", "reason": "already used by another object" }, { "field": "alias", "reason": "already used by another object" }, { "field": "display_name", "reason": "already used by another object" }, { "field": "fields", "reason": "at least one primary key field required" }, { "field": "relations[0].child_object", "reason": "does not exist" } ] } }- titlestringExample
- statusintegerExampleDefault0
- timestampstringExample
- detailobject
- invalidsobject[]
- fieldstringExample
- reasonstringExample
403
curl
curl --request POST \
--url https://api.us1.odp.optimizely.com/v3/schema/objects \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '{
"name": "",
"display_name": "",
"public_read": false,
"alias": "",
"fields": [
{
"primary": true
}
]
}'javascript
var myHeaders = new Headers();
myHeaders.append("accept", "application/json");
myHeaders.append("content-type", "application/json");
var raw = JSON.stringify({
"name": "",
"display_name": "",
"public_read": false,
"alias": "",
"fields": [
{
"primary": true
}
]
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://api.us1.odp.optimizely.com/v3/schema/objects", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));ruby
require "uri"
require "json"
require "net/http"
url = URI("https://api.us1.odp.optimizely.com/v3/schema/objects")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Post.new(url)
request["accept"] = "application/json"
request["content-type"] = "application/json"
request.body = JSON.dump({
"name": "",
"display_name": "",
"public_read": false,
"alias": "",
"fields": [
{
"primary": true
}
]
})
response = https.request(request)
puts response.read_body
python
import requests
import json
url = "https://api.us1.odp.optimizely.com/v3/schema/objects"
payload = json.dumps({
"name": "",
"display_name": "",
"public_read": False,
"alias": "",
"fields": [
{
"primary": True
}
]
})
headers = {
'accept': 'application/json',
'content-type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
200
// OK
{
"name": "",
"display_name": "",
"public_read": false,
"alias": "",
"fields": [
{
"name": "object_id",
"display_name": "New Object Identifier",
"type": "string",
"primary": true
}
],
"relations": [
{
"name": "my_relation",
"display_name": "My Relationship",
"child_object": "child",
"join_fields": [
{
"parent": "child_id",
"child": "child_id"
}
]
}
]
}400
// Bad Request
{
"title": "Bad Request",
"status": 400,
"timestamp": "2018-08-07T13:44:17.659Z",
"detail": {
"invalids": [
{
"field": "name",
"reason": "already used by another object"
}
]
}
}403
// Forbidden