Tags are not working for service creation through API call #3245

Closed
opened 2025-12-29 18:27:03 +01:00 by adam · 0 comments
Owner

Originally created by @jhanssenfavaro on GitHub (Jan 29, 2020).

Originally assigned to: @jeremystretch on GitHub.

  • Python version: 3.6.8
  • NetBox version: 2.7.1

REST API is not creating services with its related passed tags arguments.

Trying to create a service and assign a tag to

curl -X POST
http://cmdbweb/api/ipam/services/
-H 'Accept: application/json'
-H 'Authorization: Token XPTO'
-H 'Cache-Control: no-cache'
-H 'Connection: keep-alive'
-H 'Content-Type: application/json'
-H 'Host: cmdbweb'
-H 'Postman-Token: e30af3a9-499c-422e-a69f-25c15edb59b3,cae622cf-2f8d-409d-8c0c-083eca0491e1'
-H 'User-Agent: PostmanRuntime/7.15.0'
-H 'accept-encoding: gzip, deflate'
-H 'cache-control: no-cache'
-H 'content-length: 114'
-H 'cookie: csrftoken=9cVlNttRCcRJ1SP7BM7EiYsC3sRISAxekLIp385OL9cf357es3c7LOEAIt1WT2Is'
-b csrftoken=9cVlNttRCcRJ1SP7BM7EiYsC3sRISAxekLIp385OL9cf357es3c7LOEAIt1WT2Is
-d '{
"name":"testService1",
"virtual_machine": 251,
"port":"9001",
"tag": "['''tagXPTOSample''']",
"protocol": 6

}'

  • Expected Behavior
    Tag should be assigned to its service, but, no tag is assigned, only when adding manually through website. By api it's failing!

  • What happened instead?
    API replied a 200 Status Code:
    {"id":430,"device":null,"virtual_machine":{"id":251,"url":"http://cmdbweb/api/virtualization/virtual-machines/251/","name":"xptoservice.com.br"},"name":"testService1","port":9001,"protocol":{"value":"tcp","label":"TCP","id":6},"ipaddresses":[],"description":"","custom_fields":{},"created":"2020-01-29","last_updated":"2020-01-29T20:25:43.717031Z"}

Originally created by @jhanssenfavaro on GitHub (Jan 29, 2020). Originally assigned to: @jeremystretch on GitHub. * Python version: 3.6.8 * NetBox version: 2.7.1 REST API is not creating services with its related passed tags arguments. ### Trying to create a service and assign a tag to 1. curl -X POST \ http://cmdbweb/api/ipam/services/ \ -H 'Accept: application/json' \ -H 'Authorization: Token XPTO' \ -H 'Cache-Control: no-cache' \ -H 'Connection: keep-alive' \ -H 'Content-Type: application/json' \ -H 'Host: cmdbweb' \ -H 'Postman-Token: e30af3a9-499c-422e-a69f-25c15edb59b3,cae622cf-2f8d-409d-8c0c-083eca0491e1' \ -H 'User-Agent: PostmanRuntime/7.15.0' \ -H 'accept-encoding: gzip, deflate' \ -H 'cache-control: no-cache' \ -H 'content-length: 114' \ -H 'cookie: csrftoken=9cVlNttRCcRJ1SP7BM7EiYsC3sRISAxekLIp385OL9cf357es3c7LOEAIt1WT2Is' \ -b csrftoken=9cVlNttRCcRJ1SP7BM7EiYsC3sRISAxekLIp385OL9cf357es3c7LOEAIt1WT2Is \ -d '{ "name":"testService1", "virtual_machine": 251, "port":"9001", "tag": "['\''tagXPTOSample'\'']", "protocol": 6 }' - Expected Behavior Tag should be assigned to its service, but, no tag is assigned, only when adding manually through website. By api it's failing! - What happened instead? API replied a 200 Status Code: {"id":430,"device":null,"virtual_machine":{"id":251,"url":"http://cmdbweb/api/virtualization/virtual-machines/251/","name":"xptoservice.com.br"},"name":"testService1","port":9001,"protocol":{"value":"tcp","label":"TCP","id":6},"ipaddresses":[],"description":"","custom_fields":{},"created":"2020-01-29","last_updated":"2020-01-29T20:25:43.717031Z"}
adam added the type: bugstatus: accepted labels 2025-12-29 18:27:03 +01:00
adam closed this issue 2025-12-29 18:27:03 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#3245