change to scripts/upload api

This commit is contained in:
Arthur
2026-04-01 10:24:11 -07:00
parent 280bca81ef
commit 7f8dfa4427
5 changed files with 28 additions and 153 deletions

View File

@@ -386,25 +386,14 @@ A complete date & time. Returns a `datetime.datetime` object.
## Uploading Scripts via the API
Script modules can be uploaded to NetBox via the REST API by sending a `multipart/form-data` POST request to `/api/extras/script-upload/`. The caller must have the `extras.add_scriptmodule` and `core.add_managedfile` permissions.
Script modules can be uploaded to NetBox via the REST API by sending a `multipart/form-data` POST request to `/api/extras/scripts/upload/`. The caller must have the `extras.add_scriptmodule` and `core.add_managedfile` permissions.
```no-highlight
curl -X POST \
-H "Authorization: Token $TOKEN" \
-H "Accept: application/json; indent=4" \
-F "upload_file=@/path/to/myscript.py" \
http://netbox/api/extras/script-upload/
```
Alternatively, a script module can be linked to an existing data source and data file instead of uploading a file directly:
```no-highlight
curl -X POST \
-H "Authorization: Token $TOKEN" \
-H "Content-Type: application/json" \
-H "Accept: application/json; indent=4" \
http://netbox/api/extras/script-upload/ \
--data '{"data_source": 1, "data_file": 42}'
-F "file=@/path/to/myscript.py" \
http://netbox/api/extras/scripts/upload/
```
## Running Custom Scripts