Create
Used to create a new record of a data model.
URL : /api/v1/form/
URL Parameters :
- name=[string] : a valid form data model name (the same name which was defined in the template)
Method : POST
Auth required : YES
Permissions required
- Roles:
_administrator_
,developer
,operator
- Permissions:
form-<data model name>:edit
Data constraints Depends on the data model. These constraints are defined in the data model class, usually under rules()
. Check Yii2 - Validating Input
Data example
Depends on the data model structure. An object that represents a table row (Model Instance) should be sent as pairs of the field name and corresponding values.
CoreCore item create example
POST http://localhost:8080/api/v1/form?name=cores
{
"rqd_abundance": 0,
"rqd_intensity": 0,
"hole_id": 205,
"core": 278,
"site_id": 41,
"expedition_id": 1,
"program_id": 1,
"analyst": "NB",
"core_catcher": 1,
"core_type": "H",
"drilled_length": 12,
"last_section": 2,
"top_depth": 12,
"bottom_depth": 24,
"core_ondeck": "2019-04-24 10:37"
}
Success Response
Code : 201 Created
Content example
{
"rqd_abundance": 0,
"rqd_intensity": 0,
"hole_id": 205,
"core": 278,
"analyst": "NB",
"core_catcher": 1,
"core_type": "H",
"drilled_length": 12,
"last_section": 2,
"top_depth": 12,
"bottom_depth": 24,
"core_ondeck": "2019-04-24 10:37:00",
"combined_id": "5063_1_A_278",
"core_recovery_pc": 0,
"id": 335,
"igsn": "ICDP5063ECB9001",
"site_id": 41,
"expedition_id": 1,
"program_id": 1,
"archive_files": {
"filter": {
"expedition": 1,
"site": 41,
"hole": 205,
"core": 335
},
"files": []
}
}
Error Response
Condition : If 'core_type' is empty.
Code : 422 Unprocessable Entity
Content :
[
{
"field": "core_type",
"message": "core_type cannot be blank."
}
]