The JourneyApps API (V1) → 3. Creating New Objects
Creating a Single New Object
This function creates a single new object of the given type.
Relative URL | HTTP Request Method |
---|---|
/api/v1/object-type.format | POST |
json
or xml
), or leave it out.
Parameters
A hash needs to supplied containing the following:
- Attributes: Attributes as defined in your app's Data Model
- Relationships: IDs of related objects that the object belongs to specified by using the relationship name and appending it with
_id
The key of this hash has to be the name of the object type (see example below). In the following example of parameters in JSON format, the object type name is car and it has three attributes: make, model and number_plate and one relationship: it belongs to a warehouse.
Response
The response includes the single newly created object. The format of the object is the same as for Retrieving All Objects.
Example
Parameters as URL-encoded key-value pairs: (refer to Request Parameter Formats)
Parameters as JSON:
-H
parameter to curl allows you to specify a custom HTTP header.
Bulk/Batch Creating Objects
You can create multiple objects of the same type in one operation by changing the hash in your parameters to an array of hashes.
For example, by using these parameters, we would be able to create two objects at once:
An example of an API call with curl with the above parameters:
An array of all the objects that were created will be returned in the response: