one big api call (post) #16880
-
Hi, I have tried to make one big api call POST which will create multiple records.
a lot of api calls ... Is it more simple way to get it in one api call post ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Not really... welcome to REST APIs. Some systems with very complex APIs are able to do this, e.g. Salesforce which has sObject Tree, composite and composite graph endpoints. But arguably that's no longer following the REST model any more. Even they couldn't decide how to structure their API, which is why there are multiple endpoints for doing essentially the same thing. If you frequently need to create the same set of items (e.g. tenant + site + racks) then you could write a custom script for it, and then invoke it via the API. This would have the advantage of running within a single database transaction, so is all-or-nothing. But if you're going to write a custom script, you may as well just interact directly with the Django ORM inside Netbox, instead of using the REST API. Some care is needed: e.g. don't forget to call |
Beta Was this translation helpful? Give feedback.
Not really... welcome to REST APIs.
Some systems with very complex APIs are able to do this, e.g. Salesforce which has sObject Tree, composite and composite graph endpoints. But arguably that's no longer following the REST model any more. Even they couldn't decide how to structure their API, which is why there are multiple endpoints for doing essentially the same thing.
If you frequently need to create the same set of items (e.g. tenant + site + racks) then you could write a custom script for it, and then invoke it via the API. This would have the advantage of running within a single database transaction, so is all-or-nothing.
But if you're going to write a custom script, you may as well …