skip to main content
OData Method Reference : HTTP POST (create)
 

Try DataDirect Cloud Now

HTTP POST (create)

Purpose

Create an entity in an existing entity collection — a table or object in the underlying data store. The body of the POST request describes the entity to be created and can be specified in the JSON or the Atom Pub (XML) OData format. Use the Content-Type header to specify the format.
Entity descriptions include the following:
*Values for all required properties, which include those that map to an updateable column in the data store that is defined as NOT NULL, that does not have a default value, and is not automatically generated by the data source.
*Optionally, include values for property values that cannot be updated. However, in this release, DataDirect Cloud ignores these values.
*Optionally, specify values for navigation properties to create a relationship with other records.

URL

https://service.datadirectcloud.com/api/odata/<data source name><entity collection path>

Method

POST

Response

The body of the response contains the value of the new entity in the same format in which the entity definition was provided in the request. The entity value returned includes the correct values for any computed or auto-generated properties, and the Location header. The value of the Location header is the URL of the entity inserted. For example, the location header for the entity created in the preceding example may have the value.
https://service.datadirectcloud.com/api/odata/myoracle/Products(10)

Response Status

If the entity is created successfully, the OData service returns a 201 Created status. The body of the response contains the value of the new entity in the same format as the entity definition provided in the request. The entity value returned includes the correct values for any computed or auto-generated properties, as well as the Location header, which contains the URL of the entity created
If the value for a required property is omitted from the entity description, the OData service returns a 400 Bad Request response. The message provides an indication of which required property was not specified.

Authentication

Basic Authentication using the DataDirect Cloud user ID and password. The credentials used for the request must be the same credentials used to create the Data Source definition.

Authorization

Any active DataDirect Cloud user. The authenticated user must use same credentials used to create the Data Source definition.

Sample Request Payload

The following example uses the JSON format to create a new Product entity in an Oracle data source.
POST https://service.datadirectcloud.com/api/odata/myoracle/Products
{
"ID" : 10, "Name" : "Hosta",
"Description" : "With new features",
"ReleaseDate" : "\/Date(1436342315266)\/",
"Rating" : 1,
"Price" : "1.23"
}