Wrong field name fed by API breaks Datagerry

Hello,

I’ve been playing with API and mistyped “name” as “mame” while creating a new object after which Datagerry stopped working and gave me a connection page.

Example bad request

curl -kX POST -d ‘{“author_id”: 1, “type_id”: 1, “fields”: [{“name”: “hostname”, “value”: “test-rhel7”}, {“mame”: “ip”, “value”: “10.216.4.30”}]}’ -H “Content-Type: application/json” -v -u admin:admin https://127.0.0.1/rest/objects/

In the logs it says

KeyError: ‘name’

For now I just deleted wrong entry from mongodb, but it would be nice to have some protection from such mistakes.

Hello @omicron and welcome to our community,

thank you for your feedback. We will add this to our backlog.

In this POST you will find examples of how to create types, objects, categories via Rest and which properties (validation of incoming data is done via Ceberus 1) are required.

With best regards

Thank you.

I also noticed that API lets you to create an object without providing all the necessary fields (marked as required in the web interface). Is it by design?

Right.

Currently, the schemas are not validated for everything REST request. We are still working on this. Will be published with the 1.7.0 release.

https://nethinks.atlassian.net/browse/NET-488

Ok, thank you for your answers.