Creating an object: POST method¶
Creating an object is carried out by the method POST
, with the class code with the namespace specified, for example rest/crud/class_string@develop-and-test
. The object itself is passed in the body of the request in json format and in the header the json type of content Content-Type:application/json
must be specified. Auto-generated fields are optional.
Example:
curl -X POST -u demo@local:ion-demo \
-H "Content-Type:application/json" \
-d '{"string_text": "Example3", "string_miltilinetext": "Example3", "string_formattext": "Example3"}' \
https://dnt.iondv.com/rest/crud/class_string@develop-and-test/
An example of a request to the crud service to create an object dnt: test/modules/rest/crud.spec.js
/Checking crud service/POST/# creating an object (POST)
In response, the created object will be returned, in which all auto-created fields will be filled and the response code 200
will be indicated.
{
"_creator": "admin@local",
"_id": "10c77900-b96e-11e9-a7ce-314f02bd4197",
"__string": "10c77900-b96e-11e9-a7ce-314f02bd4197",
"__class": "class_string@develop-and-test",
"__classTitle": "Class \"String [0]\"",
"id": "10c77900-b96e-11e9-a7ce-314f02bd4197",
"string_text": "Example3",
"string_miltilinetext": "Example3",
"string_formattext": "Example3"
}
In case of an error, the response code will be 400
, and the response text will contain
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Bad Request</pre>
</body>
</html>