Forums

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

POST API call - {"errorMessages":[],"errors":{"summary":"The summary is invalid because it contains

Hitesh Sharma November 26, 2020

Hi There

I am trying to read data from excel from column 'Summary' and 'Description' which contains multiple lines but I am getting below error.

{"errorMessages":[],"errors":{"summary":"The summary is invalid because it contains newline characters."}}

Can someone please guide how to fix the issue ?

Here is my python code

 

# Read Json file
strGlobalVarPath = os.path.abspath(some path '/LogIssueinJira.json')
with open(strGlobalVarPath,mode='r') as json_file:
json_data = json.load(json_file)
json_file.close()

url = baseURL + '/rest/api/2/issue'
headers = {'Content-Type': 'application/json'}

#Read Jira Defect file from sys location
data_folder = Path("some path")
file_to_open = data_folder / "Jiratemplate.xlsx"
df = pandas.read_excel(file_to_open)

#Fetch the list value from summary and description
SummaryList = list(df['Summary'])
DescriptionList = list(df['Description'])

#POST call to JIRA to logged defect
value1 = 0
value2 = 0
while value1 in range(0,len(SummaryList)) and value2 in range(0,len(DescriptionList)):
w1 = SummaryList[value1]
w2 = DescriptionList[value2]
json_data['fields']['summary'] = w1
json_data['fields']['description'] = w2
payload = json.dumps(json_data)
r = requests.post(url, data=payload, headers=headers, auth=(username, password))

 

  

2 answers

0 votes
Hitesh Sharma November 26, 2020

Thanks @Hana

But looks to me problem in below line of code.

SummaryList = list(df['Summary'])

 In excel, Summary column contains below data as in

abcde

fghij

however SummaryList return only abcde not fghij

I tried strip but not working though.

0 votes
Hana Kučerová
Community Champion
November 26, 2020

Hi @Hitesh Sharma ,

I think what you need to do is remove newline characters from w1. I don't have much experience with Python, but I believe you will be able to find some appropriate way, how to do it, probably something like 

w1.strip('\n')
Hitesh Sharma November 26, 2020

Thanks @Hana

But looks to me problem in below line of code.

SummaryList = list(df['Summary'])

 In excel, Summary column contains below data as in

abcde

fghij

however SummaryList return only abcde not fghij

I tried strip but not working though.

Suggest an answer

Log in or Sign up to answer