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

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

This widget could not be displayed.

Try this instead:

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

 

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).

 

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.

This widget could not be displayed.

This worked. Thanks for the help everyone.  

issue.update(fields={"customfield_10007":featureid.split()})
issue.update(fields={"labels":tags.split(';')})

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted 2 hours ago in Featured Groups

Hi! I'm Cameron Deatsch, Head of Server at Atlassian and I'm hosting an AMA next week.

Hey team! I'm Cameron Deatsch, Head of Server at Atlassian. I'll be hosting an AMA over in our Questions section of the Community next Monday, so shoot me your questions, upvote others' question...

19 views 0 2
View post

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you