Set interface 802.1Q mode to null via REST API #3434

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

Originally created by @keliansb on GitHub (Mar 4, 2020).

Environment

  • Python version: 3.6.8
  • NetBox version: 2.7.8

Proposed Functionality

Currently it is not possible to remove the 802.1q mode from API. From the documentation, we can only choose a string from an enumeration : [ access, tagged, tagged-all ] :

doc

Use Case

If we configure a 802.1q mode on an interface (Access, Tagged or Tagged All), we can only remove it by deleting and recreating the interface (from the API, from the UI there is a cross to unset the field) :

802.1q mode

Database Changes

No database change should be required.

External Dependencies

No external dependency.

Originally created by @keliansb on GitHub (Mar 4, 2020). <!-- NOTE: IF YOUR ISSUE DOES NOT FOLLOW THIS TEMPLATE, IT WILL BE CLOSED. This form is only for proposing specific new features or enhancements. If you have a general idea or question, please post to our mailing list instead of opening an issue: https://groups.google.com/forum/#!forum/netbox-discuss NOTE: Due to an excessive backlog of feature requests, we are not currently accepting any proposals which significantly extend NetBox's feature scope. Please describe the environment in which you are running NetBox. Be sure that you are running an unmodified instance of the latest stable release before submitting a bug report. --> ### Environment * Python version: 3.6.8 <!-- Example: 3.6.9 --> * NetBox version: 2.7.8 <!-- Example: 2.7.3 --> <!-- Describe in detail the new functionality you are proposing. Include any specific changes to work flows, data models, or the user interface. --> ### Proposed Functionality Currently it is not possible to remove the 802.1q mode from API. From the documentation, we can only choose a string from an enumeration : [ access, tagged, tagged-all ] : ![doc](https://user-images.githubusercontent.com/22099779/75892683-04324300-5e32-11ea-94e3-420fdf06a85e.png) <!-- Convey an example use case for your proposed feature. Write from the perspective of a NetBox user who would benefit from the proposed functionality and describe how. ---> ### Use Case If we configure a 802.1q mode on an interface (Access, Tagged or Tagged All), we can only remove it by deleting and recreating the interface (from the API, from the UI there is a cross to unset the field) : ![802.1q mode](https://user-images.githubusercontent.com/22099779/75892600-e369ed80-5e31-11ea-9253-2f463e364e76.PNG) <!-- Note any changes to the database schema necessary to support the new feature. For example, does the proposal require adding a new model or field? (Not all new features require database changes.) ---> ### Database Changes No database change should be required. <!-- List any new dependencies on external libraries or services that this new feature would introduce. For example, does the proposal require the installation of a new Python package? (Not all new features introduce new dependencies.) --> ### External Dependencies No external dependency.
adam closed this issue 2025-12-29 18:29:05 +01:00
Author
Owner

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

Setting {"mode": null} on the interface should work. Have you tried that?

@jeremystretch commented on GitHub (Mar 4, 2020): Setting `{"mode": null}` on the interface should work. Have you tried that?
Author
Owner

@keliansb commented on GitHub (Mar 5, 2020):

Yes I've tried with {"mode": null} :

curl -X PATCH "https://<url>/api/dcim/interfaces/391/" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"mode\": null}"

I get this response :

<!DOCTYPE html>
<html lang="en">

<head>
    <title>Server Error</title>
    <link rel="stylesheet" href="/static/bootstrap-3.4.1-dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="/static/font-awesome-4.7.0/css/font-awesome.min.css">
    <meta charset="UTF-8">
</head>

<body>
    <div class="container-fluid">
        <div class="row">
            <div class="col-md-6 col-md-offset-3">
                <div class="panel panel-danger" style="margin-top: 200px">
                    <div class="panel-heading">
                        <strong>
                            <i class="fa fa-warning"></i>
                            Server Error
                        </strong>
                    </div>
                    <div class="panel-body">
                        
                            <p>
                                There was a problem with your request. Please contact an administrator.
                            </p>
                        
                        <hr />
                        <p>
                            The complete exception is provided below:
                        </p>
<pre><strong>&lt;class &#39;django.db.utils.IntegrityError&#39;&gt;</strong><br />
null value in column &quot;mode&quot; violates not-null constraint
DETAIL:  Failing row contains (391, ethernet1/1/8, 40gbase-x-qsfpp, f, , 6, 0c:9c:fd:6d:da:08, null, t, 1554, null, null, null, null, null, null, null).
</pre>
                        <p>
                            If further assistance is required, please post to the <a href="https://groups.google.com/forum/#!forum/netbox-discuss">NetBox mailing list</a>.
                        </p>
                        <div class="text-right">
                            <a href="/" class="btn btn-primary">Home Page</a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>

</html>
@keliansb commented on GitHub (Mar 5, 2020): Yes I've tried with `{"mode": null}` : ``` curl -X PATCH "https://<url>/api/dcim/interfaces/391/" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"mode\": null}" ``` I get this response : ``` <!DOCTYPE html> <html lang="en"> <head> <title>Server Error</title> <link rel="stylesheet" href="/static/bootstrap-3.4.1-dist/css/bootstrap.min.css"> <link rel="stylesheet" href="/static/font-awesome-4.7.0/css/font-awesome.min.css"> <meta charset="UTF-8"> </head> <body> <div class="container-fluid"> <div class="row"> <div class="col-md-6 col-md-offset-3"> <div class="panel panel-danger" style="margin-top: 200px"> <div class="panel-heading"> <strong> <i class="fa fa-warning"></i> Server Error </strong> </div> <div class="panel-body"> <p> There was a problem with your request. Please contact an administrator. </p> <hr /> <p> The complete exception is provided below: </p> <pre><strong>&lt;class &#39;django.db.utils.IntegrityError&#39;&gt;</strong><br /> null value in column &quot;mode&quot; violates not-null constraint DETAIL: Failing row contains (391, ethernet1/1/8, 40gbase-x-qsfpp, f, , 6, 0c:9c:fd:6d:da:08, null, t, 1554, null, null, null, null, null, null, null). </pre> <p> If further assistance is required, please post to the <a href="https://groups.google.com/forum/#!forum/netbox-discuss">NetBox mailing list</a>. </p> <div class="text-right"> <a href="/" class="btn btn-primary">Home Page</a> </div> </div> </div> </div> </div> </div> </body> </html> ```
Author
Owner

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

I'm not able to replicate this on v2.7.8. The following request succeeds as expected:

curl -X PATCH -H "Authorization: Token ${TOKEN}" \
-H "Cntent-Type: application/json" \
-H "Accept: application/json; indent=4" \
http://localhost:8000/api/dcim/interfaces/69000/ \
--data '{"mode": null}'
{
    "id": 69000,
    ...
    "mode": null,
    ...
}

Are you sure you're running v2.7.8 and have restarted the WSGI processes since the upgrade? Did you encounter any errors when applying database migrations?

@jeremystretch commented on GitHub (Mar 5, 2020): I'm not able to replicate this on v2.7.8. The following request succeeds as expected: ``` curl -X PATCH -H "Authorization: Token ${TOKEN}" \ -H "Cntent-Type: application/json" \ -H "Accept: application/json; indent=4" \ http://localhost:8000/api/dcim/interfaces/69000/ \ --data '{"mode": null}' { "id": 69000, ... "mode": null, ... } ``` Are you sure you're running v2.7.8 and have restarted the WSGI processes since the upgrade? Did you encounter any errors when applying database migrations?
Author
Owner

@keliansb commented on GitHub (Mar 5, 2020):

Sorry, didn't pay attention to the instance I was testing... It was a v2.7.4. Just tried with my up to date instance and everything works! Thank you and sorry for the wasted time.

@keliansb commented on GitHub (Mar 5, 2020): Sorry, didn't pay attention to the instance I was testing... It was a v2.7.4. Just tried with my up to date instance and everything works! Thank you and sorry for the wasted time.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#3434