Getting an error when POSTing to /api/extras/config-contexts/ #2921

Closed
opened 2025-12-29 18:23:27 +01:00 by adam · 1 comment
Owner

Originally created by @misch42 on GitHub (Oct 1, 2019).

Hi,

I want to add data to a config-context. So I tried

curl -X POST -H "Authorization: Token ..." -H "Content-Type: application/json" -H "Accept: application/json; indent=4" http://10.57.0.1:8000/api/extras/config-contexts/ --data '{ "name": "string", "data": "value" }'

The result was:
{
"data": [
"JSON data must be in object form. Example: {"foo": 123}"
]
}

What am I doing wrong?

Environment

  • Ubuntu 19.04
  • Python version: 3.7.3
  • NetBox version: 2.6.5

Steps to Reproduce

  1. see curl command above

I also added a "site": 1 to the request, same error.

Expected Behavior

Add config-context data to the database.

Observed Behavior

See error above.

How can I add the data in JSON format? Is it a bug or I am just entering the data in incorrect format?

Originally created by @misch42 on GitHub (Oct 1, 2019). Hi, I want to add data to a config-context. So I tried curl -X POST -H "Authorization: Token ..." -H "Content-Type: application/json" -H "Accept: application/json; indent=4" http://10.57.0.1:8000/api/extras/config-contexts/ --data '{ "name": "string", "data": "value" }' The result was: { "data": [ "JSON data must be in object form. Example: {\"foo\": 123}" ] } What am I doing wrong? ### Environment * Ubuntu 19.04 * Python version: 3.7.3 * NetBox version: 2.6.5 ### Steps to Reproduce 1. see curl command above I also added a "site": 1 to the request, same error. ### Expected Behavior Add config-context data to the database. ### Observed Behavior See error above. How can I add the data in JSON format? Is it a bug or I am just entering the data in incorrect format?
adam closed this issue 2025-12-29 18:23:27 +01:00
Author
Owner

@misch42 commented on GitHub (Oct 1, 2019):

Solved: I was too stupid to write correct JSON objects.

Works: --data '{ "name": "string", "data": { "data": 1 } }'

@misch42 commented on GitHub (Oct 1, 2019): Solved: I was too stupid to write correct JSON objects. Works: --data '{ "name": "string", "data": { "data": 1 } }'
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#2921