It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Python API update

Joe Simonsen I'm New Here Tuesday

Been searching around for a solid day and can't seem to find what I'm looking for. Trying to run a python script to update a single custom field on JIRA Service Desk. I originally wrote a script that worked :

```

from jira import JIRA

def main():

options = {'server': 'https://xxx.atlassian.net'}
jira = JIRA(options, basic_auth=("jUSER", "API_Key"))
issue = jira.issue('GISSUE-123')

issue.update(fields={'customfield_10130': 'New Value'})

print (issue.fields.project.key)
print (issue.fields.issuetype.name)
print (issue.fields.reporter.displayName)
print (issue.fields.summary)
print (issue.fields.project.id)
print(issue.fields.customfield_10130)


if __name__== "__main__" :
main()

```

However I am unable to user the JIRA module in this environment for reasons. I can however use requests which led me to write:

```

import requests
from requests.auth import HTTPBasicAuth
import json

url = "https://xxx.atlassian.net/rest/api/3/issue/ISSUE-123"

auth = HTTPBasicAuth("USER", "KEY")

update = {'customfield_10130': 'New Value'}

headers = {"Accept": "application/json"}

x = requests.post(url, json=update, headers=headers, auth=auth)

```

BUt this doesn't seem to do anything. I'm probably configuring this wrong as I don't have much experience with the request module here. 

Any help or advice would be great!

0 answers

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira

How InVision centralized their tools and scaled their remote team with Atlassian and Slack

Hi Atlassian Community, We recently published a case study that we thought you might be interested in. Learn about how InVision built their fully remote company’s culture using Atlassian and Slack ...

309 views 0 1
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you