Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pynautobot 1.1.0 Errors when trying to insert a cable record #44

Closed
gneville-ot opened this issue Apr 26, 2022 · 1 comment · Fixed by #47
Closed

pynautobot 1.1.0 Errors when trying to insert a cable record #44

gneville-ot opened this issue Apr 26, 2022 · 1 comment · Fixed by #47
Assignees
Labels
bug Something isn't working

Comments

@gneville-ot
Copy link

I'm using pynautobot 1.1.0 with nautobot 1.3.1 and trying to insert a new cable entry but it errors. The same works with pynautobot 1.0.4 (with nautobot 1.3.1)

Example code:

cable_record = {'termination_a_type': 'dcim.interface', 'termination_a_id': source.id, 'termination_b_type': 'dcim.interface', 'termination_b_id': target.id, 'status': 'connected'}

nb.dcim.cables.create(cable_record)

This errors with:

  File "/home/appuser/.local/lib/python3.8/site-packages/pynautobot/core/endpoint.py", line 293, in create
    req = Request(
  File "/home/appuser/.local/lib/python3.8/site-packages/pynautobot/core/query.py", line 339, in post
    return self._make_call(verb="post", data=data)
  File "/home/appuser/.local/lib/python3.8/site-packages/pynautobot/core/query.py", line 241, in _make_call
    raise RequestError(req)
pynautobot.core.query.RequestError: The request failed with code 406 Not Acceptable: {'detail': 'Invalid version in "Accept" header. Supported versions are 1.2, 1.3'}

I'm getting up pynautobot with the following:

nautobot = nb_api(url=nb_url, token=nb_token)

I have tried to add api_version="1.3" but it fails with the same.

Doing some debugging if I edit pynautobot/core/query.pyand print the headers in _make_call after if self.api_version: I see the following:

{'Content-Type': 'application/json;', 'authorization': 'Token <token>', 'accept': "application/json; version={'termination_a_type': 'dcim.interface', 'termination_a_id': 'cd80ed0b-96c9-49ca-afa2-78d79a18cfaf', 'termination_b_type': 'dcim.interface', 'termination_b_id': 'e6651be5-16bc-4828-a173-5559ff482309', 'status': 'connected'}"}

So it looks like the headers are getting mangled with the post data.

If I revert to 1.0.4 everything is fine, the headers are normal:

{'Content-Type': 'application/json;', 'authorization': 'Token <token>'}
@FragmentedPacket
Copy link
Contributor

Sorry about all the regressions. We're planning to refactor and increase test coverage but will try and get a fix out today or tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
No open projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants