Support for bulk creation of objects via API #1275

Closed
opened 2025-12-29 16:30:59 +01:00 by adam · 5 comments
Owner

Originally created by @dirtycajunrice on GitHub (Oct 3, 2017).

Issue type

[X] Feature request
[ ] Bug report
[ ] Documentation

Description

Multi-entry API calls would make automation much easier. I have scripted a "New Customer.py" which creates the Tenant, VRF, 10xVLANs, 10xPrefixes, and about 50 initial IPs. Currently, my options are to paste it out to CSV and import it section by section or to create a loop for the HTTP PUSH request which is a nightmare for error checking.

Browsable API example:

[
    {
        "name": "Cust 2",
        "slug": "cust-2",
        "group": 1
    },
    {
        "name": "Cust 3",
        "slug": "cust-3",
        "group": 1
    }
]

Thoughts?

Originally created by @dirtycajunrice on GitHub (Oct 3, 2017). ### Issue type [X] Feature request <!-- Requesting the implementation of a new feature --> [ ] Bug report <!-- Reporting unexpected or erroneous behavior --> [ ] Documentation <!-- Proposing a modification to the documentation --> ### Description Multi-entry API calls would make automation much easier. I have scripted a "New Customer.py" which creates the Tenant, VRF, 10xVLANs, 10xPrefixes, and about 50 initial IPs. Currently, my options are to paste it out to CSV and import it section by section or to create a loop for the HTTP PUSH request which is a nightmare for error checking. Browsable API example: ``` [ { "name": "Cust 2", "slug": "cust-2", "group": 1 }, { "name": "Cust 3", "slug": "cust-3", "group": 1 } ] ``` Thoughts?
adam added the type: feature label 2025-12-29 16:30:59 +01:00
adam closed this issue 2025-12-29 16:30:59 +01:00
Author
Owner

@Zimeon- commented on GitHub (Oct 3, 2017):

Ran into the same issue that it didn't accept multiple entries when posting a JSON. Your example is missing [] and a comma between the entries but none the less it doesn't support it. Ended up just making multiple post entries in the script but bulk data in a single json would be nice.

@Zimeon- commented on GitHub (Oct 3, 2017): Ran into the same issue that it didn't accept multiple entries when posting a JSON. Your example is missing [] and a comma between the entries but none the less it doesn't support it. Ended up just making multiple post entries in the script but bulk data in a single json would be nice.
Author
Owner

@dirtycajunrice commented on GitHub (Oct 3, 2017):

@Zimeon- fixed example. Thanks! Do you have request.error_code and request.response data from each push? And if so how are you logically checking those? Dict?

@dirtycajunrice commented on GitHub (Oct 3, 2017): @Zimeon- fixed example. Thanks! Do you have request.error_code and request.response data from each push? And if so how are you logically checking those? Dict?
Author
Owner

@Zimeon- commented on GitHub (Oct 4, 2017):

I simply stored the response code and moved along. After that I manually verified the failed ones by hand as I just had to import stuff once from an old db to netbox.

@Zimeon- commented on GitHub (Oct 4, 2017): I simply stored the response code and moved along. After that I manually verified the failed ones by hand as I just had to import stuff once from an old db to netbox.
Author
Owner

@jeremystretch commented on GitHub (Oct 16, 2017):

This seems simple enough to implement in the writable serializers. We might want to restrict the total number of objects able to be created in one request though: It might be reasonable to reuse the MAX_PAGE_SIZE configuration parameter for that purpose.

@jeremystretch commented on GitHub (Oct 16, 2017): This seems [simple enough to implement](https://stackoverflow.com/questions/14666199/how-do-i-create-multiple-model-instances-with-django-rest-framework#answer-40253309) in the writable serializers. We might want to restrict the total number of objects able to be created in one request though: It might be reasonable to reuse the `MAX_PAGE_SIZE` configuration parameter for that purpose.
Author
Owner

@dirtycajunrice commented on GitHub (Oct 17, 2017):

Yes i agree that MAX_PAGE_SIZE would safely limit to (500?) by default

@dirtycajunrice commented on GitHub (Oct 17, 2017): Yes i agree that MAX_PAGE_SIZE would safely limit to (500?) by default
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#1275