/api/secrets/get-session-key without a trailing slash returns 405 Method Not Allowed #3519

Closed
opened 2025-12-29 18:29:37 +01:00 by adam · 2 comments
Owner

Originally created by @dmfigol on GitHub (Mar 29, 2020).

Environment

  • Python version: 3.7.6
  • NetBox version: 2.7.9

Steps to Reproduce

  1. POST /api/secrets/get-session-key with payload {"private_key": "whatever"}

Expected Behavior

Expected to work it the same regardless if the trailing slash is there or not, like the rest of API endpoints

Observed Behavior

Response is 405 Method Not Allowed

Originally created by @dmfigol on GitHub (Mar 29, 2020). ### Environment * Python version: 3.7.6 * NetBox version: 2.7.9 <!-- Describe in detail the exact steps that someone else can take to reproduce this bug using the current stable release of NetBox (or the current beta release where applicable). Begin with the creation of any necessary database objects and call out every operation being performed explicitly. If reporting a bug in the REST API, be sure to reconstruct the raw HTTP request(s) being made: Don't rely on a wrapper like pynetbox. --> ### Steps to Reproduce 1. POST `/api/secrets/get-session-key` with payload `{"private_key": "whatever"}` <!-- What did you expect to happen? --> ### Expected Behavior Expected to work it the same regardless if the trailing slash is there or not, like the rest of API endpoints <!-- What happened instead? --> ### Observed Behavior Response is **405 Method Not Allowed**
adam closed this issue 2025-12-29 18:29:37 +01:00
Author
Owner

@jeremystretch commented on GitHub (Mar 30, 2020):

Expected to work it the same regardless if the trailing slash is there or not, like the rest of API endpoints

Just a note: the trailing slash is always needed. Without it, a 302 redirect is returned for the correct URL.

@jeremystretch commented on GitHub (Mar 30, 2020): > Expected to work it the same regardless if the trailing slash is there or not, like the rest of API endpoints Just a note: the trailing slash is always needed. Without it, a 302 redirect is returned for the correct URL.
Author
Owner

@jeremystretch commented on GitHub (Mar 30, 2020):

I'm going to close this as this is expected behavior. Per the RuntimeError exception (raised when DEBUG is true):

RuntimeError: You called this URL via POST, but the URL doesn't end in a slash and you have APPEND_SLASH set. Django can't redirect to the slash URL while maintaining POST data. Change your form to point to localhost:8000/api/secrets/get-session-key/ (note the trailing slash), or set APPEND_SLASH=False in your Django settings.

@jeremystretch commented on GitHub (Mar 30, 2020): I'm going to close this as this is expected behavior. Per the RuntimeError exception (raised when `DEBUG` is true): > RuntimeError: You called this URL via POST, but the URL doesn't end in a slash and you have APPEND_SLASH set. Django can't redirect to the slash URL while maintaining POST data. Change your form to point to localhost:8000/api/secrets/get-session-key/ (note the trailing slash), or set APPEND_SLASH=False in your Django settings.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#3519