Getting {"customfield_10007":"data was not an array"}} attempting issue update w/ jira python

Malcolm Carlson April 8, 2017

Have the following method to pull data from a csv to write create a Jira issue.  I first create issue with Summary and Description.  I then want to update the issue to include the Feature ID field(type is label).  I also want to update the Labels field with "tags" column from the csv.(importing from Rally csv into Jira)

Does featureid need to be converted to a list, then passed into the update?

for row in df2.iterrows():
summ = str(df2.loc[row[0], 'Summary'])
desc = str(df2.loc[row[0], 'Description'])
#These have to be updated
featureid = str(df2.loc[row[0], 'Feature ID'])# customfield_10007, type is label

#owner = str(df2.loc[row[0], 'Assignee']) # need to update usernames or have a lookup
tags = str(df2.loc[row[0], 'Labels']) # Needs to return an array

try:
jira_options = {'server': jira_url}
jira = JIRA(options=jira_options, basic_auth=(jira_user, jira_password))
log.info("Connecting to JIRA: %s" % jira_url)

#customfield_10007=featureid, assignee=owner, description=desc,           labels=tags,
issue = jira.create_issue(project={'key': jira_project_key},
summary = summ,
description = desc,
issuetype = {'name': jira_issue_type})
print issue ,'was created.'
issue.update(customfield_10007={'Feature ID':featureid})  #need to convert to list before I can update?

except JIRAError, e:
log.error("Failed to connect to JIRA: %s" % e)
print "Failed to connect to JIRA ",e
return None

2 answers

0 votes
Malcolm Carlson April 11, 2017

This worked. Thanks for the help everyone.  

issue.update(fields={"customfield_10007":featureid.split()})
issue.update(fields={"labels":tags.split(';')})
0 votes
Phillip Ponzer [Cprime]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 10, 2017

Try this instead:

issue.update(fields={"customfield_10007":featureid})

 

Phillip Ponzer [Cprime]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 10, 2017

If I could, I would, but it might also be helpful for us if you surrounded your code in using the code macro (click the <> button when you edit your answer).

Malcolm Carlson April 10, 2017

 

def getdatafromcsv():
    mycols = ['Formatted ID', 'Name', 'Owner', 'Description', 'Tags']
    df = pd.read_csv(mycsv)
    df1 = df[mycols]
    df2 = df1.rename(columns={'Name': 'Summary',
                              'Formatted ID': 'Feature ID',
                              'Owner': 'Assignee',
                              'Description': 'Description',
                              'Tags': 'Labels'})

    for row in df2.iterrows():
        summ = str(df2.loc[row[0], 'Summary'])
        desc = str(df2.loc[row[0], 'Description'])
        #These have to be updated
        featureid = str(df2.loc[row[0], 'Feature ID'])# customfield_10007, type is label


        owner = str(df2.loc[row[0], 'Assignee'])        # need to update usernames or have a lookup
        tags = str(df2.loc[row[0], 'Labels'])   # Needs to return an array

        try:
            jira_options = {'server': jira_url}
            jira = JIRA(options=jira_options, basic_auth=(jira_user, jira_password))
            log.info("Connecting to JIRA: %s" % jira_url)
            #customfield_10007=featureid, assignee=owner, description=desc, labels=tags,
            issue = jira.create_issue(project={'key': jira_project_key},
                                          summary = summ,
                                          description = desc,
                                          issuetype = {'name': jira_issue_type})
            print issue ,'was created.'
            #getissue = jira.issue('issue')

            issue.update(fields={"customfield_10007":featureid})

        except JIRAError, e:
            log.error("Failed to connect to JIRA: %s" % e)
            print "Failed to connect to JIRA ",e
            return None

    outrows = len(df2)
    log.info(outrows, ' Features written to JIRA.')

Output from above:
text: data was not an array
 
 response headers = {'X-AUSERNAME': 'jira_user', 'X-AREQUESTID': '1248x4728x1', 'X-Content-Type-Options': 'nosniff', 'Content-Encoding': 'gzip', 'Transfer-Encoding': 'chunked', 'X-Seraph-LoginReason': 'OK', 'Vary': 'User-Agent', 'X-ASESSIONID': '1lpzagg', 'Connection': 'close', 'Cache-Control': 'no-cache, no-store, no-transform', 'Date': 'Tue, 11 Apr 2017 01:48:58 GMT', 'Content-Type': 'application/json;charset=UTF-8', 'X-ASEN': 'SEN-L9516098'}
 response text = {"errorMessages":[],"errors":{"customfield_10007":"data was not an array"}}

Process finished with exit code 0

Not sure how to get the output into a list.  I tried mylist = featureid.split() to get content into a list but that didn't work either.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events