Create An Entity

To create an entity, we need to make the following HTTP request

Request

post
/api/v1/{entity-type}
Create a record for entity-type
Parameters
Path
entity-type*
The type of entity to create
Query
mode
Query parameter whose value can be async if creating an entity should be asynchronously handled
callbackUrl
Query parameter whose value will be a web-hook url. The webook will be called once the entity is created in the registry. This is applicable only for async mode
Header
content-type*
Set to application/json
authorization
Set to Bearer {access-token} if roles in schema config is not anonymous else this can be empty
Body
...*
The entity's data
Responses
200: OK
Success Response of entity Created
Sample Request Body for Teacher as Entity-Type
{
"name": "Sunbird",
"school": "UP Public School",
"phoneNumber": "1234567890",
"subject": "Math"
}
Important Fields in Response Body
Field
Type
Description
result.{entity-type}.osid
string
The ID of the create entity in the registry, used for retrieval and modification of the entity

Usage

So to create a Teacher entity named Pranav Agate who teaches Math at UP Public School, we would make the following API call:

cURL

curl --location \
--request 'POST' \
--header 'content-type: application/json' \
--data-raw '{
{
"name": "Pranav Agate",
"school": "UP Public School",
"subject": "Math",
"contact": "1234567890"
}
}' \
'{registry-url}/api/v1/{entity-type}/'

HTTPie

printf '{
"name": "Pranav Agate",
"school": "UP Public School",
"subject": "Math",
"contact": "1234567890"
}' | http post \
'{registry-url}/api/v1/{entity-type}' \
'content-type: application/json'
{registry-url} is usually http://localhost:{port}. The port can be found under the registry section in the docker-compose.yml file and is usually 8081