Create an object via the REST API

Hi,

How can I create and update an object?
Via /rest/object/type/ID it’s possible to query all the objects for a certain type.

But I can not create or update an object.
I tried to PUT and POST a json string wth the fields to /rest/object/type/ID but this returns the error “description”:“The method is not allowed for the requested URL.”

Stef

Hello @StefCoene

You can create a new object via the route /rest/object/ using a HTTP POST request.
The PublicID will be assigned automatically.

You can update the object with rest/object/PUBLIC_ID - (example: rest/object/1) via HTTP PUT.
At the moment you can only replace a complete object. The changing of single elements within the object is still in planning.

For authentication of the rest you can put a valid JWToken in the Authorization Header of your request or alternatively use HTTP Basic Auth.

API routes can be viewed in the documentation under api/rest, but we are currently in the process of rebuilding the complete REST api to a new concept NET-488.

Therefore the object routes are currently not listed in the documentation. But maybe the other routes will help you.

It is planned to migrate the object routes up to version 1.6. The release is planned for Apr. 30, 2021, at which time all object routes should be fully documented. Until then you can contact me if you have questions about the rest api.

Hi,

I was trying to do that, but I didn’t knew what syntax to use.

With some trial and error, I found that you need a json string with author_id and type_id. And for each field the name and value.

In case someone else is interested, this is the json:

{
“author_id”: 1,
“type_id”: 1,
“fields”: [
{
“name”: “first-field”,
“value”: “some text”
},
{
“name”: “second-field”,
“value”: “12345”
}
]
}

I use curl to post this:

curl -X POST -d @post.json -H “Content-Type: application/json” -v -u admin:admin http://1.2.3.4/rest/object/

Stef