Schedule script via API #10825

Closed
opened 2025-12-29 21:36:21 +01:00 by adam · 1 comment
Owner

Originally created by @kochargs on GitHub (Feb 28, 2025).

Deployment Type

Self-hosted

NetBox Version

v3.7.8, v4.1.11

Python Version

3.10

Steps to Reproduce

payload = json.dumps(
        {
            "data": "",
            "schedule_at": schedule_at,
            "interval": interval,
            "commit": True,
        }
    )

schedule_at : "2025-02-28 11:59:00"
interval: 1

response = requests.post(script_url, headers=HEADERS, data=payload)

While scheduling a script via API, if i use the above payload for a netbox running 3.7.8, 2 observations are seen

  1. The URL returned for script is named like
    http://localhost:8000/api/extras/scripts/all_creds.CredentialStore/
    However, if i send the same POST request to netbox running 4.1.11, the URL returned is with ID
    http://x.x.x.x/api/extras/scripts/54/

  2. I am able to successfully able to schedule the script on 3.7.8 with that payload however on v4.1.11, i am getting this error with exact same payload.
    {"error": "'Script' object has no attribute 'scheduling_enabled'",
    "exception": "AttributeError", "netbox_version": "4.1.11", "python_version": "3.12.3"}

I am ensuring that i have set, scheduling_enabled = True, although it doesn't matter here

class CredentialStore(Script):
    class Meta:
        name = "Credential Store"
        description = "Credential Store for Netbox Scripts"
        job_timeout = 86400
        scheduling_enabled = True
  1. Having named URLS make is so much easier in case i have a netbox script with multiple classes, so to reference which script i want to execute / schedule is so much easier with scriptname.module approach rather than figuring out the ID of that script dynamically.

Expected Behavior

What is the correct approach to schedule a script via API on v4.1.11 ?
How can i convert the URL nomenclature for /api/scripts from ID based to name based as in v.3.7.8

Observed Behavior

What is the correct approach to schedule a script via API on v4.1.11 ?
How can i convert the URL nomenclature for /api/scripts from ID based to name based as in v.3.7.8

Originally created by @kochargs on GitHub (Feb 28, 2025). ### Deployment Type Self-hosted ### NetBox Version v3.7.8, v4.1.11 ### Python Version 3.10 ### Steps to Reproduce ``` payload = json.dumps( { "data": "", "schedule_at": schedule_at, "interval": interval, "commit": True, } ) ``` schedule_at : "2025-02-28 11:59:00" interval: 1 response = requests.post(script_url, headers=HEADERS, data=payload) While scheduling a script via API, if i use the above payload for a netbox running 3.7.8, 2 observations are seen 1. The URL returned for script is named like http://localhost:8000/api/extras/scripts/all_creds.CredentialStore/ However, if i send the same POST request to netbox running 4.1.11, the URL returned is with ID http://x.x.x.x/api/extras/scripts/54/ 2. I am able to successfully able to schedule the script on 3.7.8 with that payload however on v4.1.11, i am getting this error with exact same payload. {"error": "'Script' object has no attribute 'scheduling_enabled'", "exception": "AttributeError", "netbox_version": "4.1.11", "python_version": "3.12.3"} I am ensuring that i have set, scheduling_enabled = True, although it doesn't matter here ``` class CredentialStore(Script): class Meta: name = "Credential Store" description = "Credential Store for Netbox Scripts" job_timeout = 86400 scheduling_enabled = True ``` 3. Having named URLS make is so much easier in case i have a netbox script with multiple classes, so to reference which script i want to execute / schedule is so much easier with scriptname.module approach rather than figuring out the ID of that script dynamically. ### Expected Behavior What is the correct approach to schedule a script via API on v4.1.11 ? How can i convert the URL nomenclature for /api/scripts from ID based to name based as in v.3.7.8 ### Observed Behavior What is the correct approach to schedule a script via API on v4.1.11 ? How can i convert the URL nomenclature for /api/scripts from ID based to name based as in v.3.7.8
adam closed this issue 2025-12-29 21:36:22 +01:00
Author
Owner

@jeremystretch commented on GitHub (Feb 28, 2025):

What is the correct approach to schedule a script via API on v4.1.11 ?

Please use GitHub's discussions feature for assistance. Bug reports are only for reporting reproducible problems with the current stable release of NetBox.

@jeremystretch commented on GitHub (Feb 28, 2025): > What is the correct approach to schedule a script via API on v4.1.11 ? Please use GitHub's [discussions](https://github.com/netbox-community/netbox/discussions/new?category=help-wanted) feature for assistance. Bug reports are only for reporting reproducible problems with the current stable release of NetBox.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#10825