Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to add option to Select list via python and API

Etai Leers
Contributor
August 2, 2022

Hi,
I took this from Atlassian documentation.
I got 401 Response. anyone know why?


 

import requests
from requests.auth import HTTPBasicAuth
import json

customers_id = "10163"
contextId = "int64"

url = "https://MY_DOMAIN.atlassian.net/rest/api/3/field/{customers_id}/context/{contextId}/option"

auth = HTTPBasicAuth("MY_EMAIL", "MY_API_TOKEN")

headers = {
   "Accept": "application/json",
   "Content-Type": "application/json"
}

payload = json.dumps( {
  "options": [
    {
      "disabled": "false",
      "value": "Scranton"
    },
    {
      "optionId": "10000",
      "disabled": "true",
      "value": "Manhattan"
    },
    {
      "disabled": "false",
      "value": "The Electric City"
    }
  ]
} )

response = requests.request(
   "POST",
   url,
   data=payload,
   headers=headers,
   auth=auth
)

print(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")))

0 answers

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events