I'm new to python, I'm reading csv file having 2 columns as ID and Filepath (headers not present). Trying to enter the ID into the URL and filepath into the below rest api call. Can't get the values of the row. If the value at row[0] is TDEVOPS-1 it's returning numeric value.
import csv
filename1 = 'E:\\Upload-PM\\attachment.csv'
with open(filename1, 'rb') as csvfile:
datareader = csv.reader(csvfile)
for row in csvfile.readlines():
urlvalue = "https://<url>.atlassian.com/rest/api/3/issue/" + str({row[0]}) + "/attachments"
url = urlvalue
print(url)
headers = {"X-Atlassian-Token": "nocheck"}
files = {'file': open(row[1], 'rb')}
r = requests.post(url, auth=('<email>','<token>'), files=files, headers=headers)
print(r.status_code)
print(r.text)
Input:
TDEVOPST-5,E:\Upload-PM\att.csv
TDEVOPST-2,E:\Upload-PM\att2.csv
TDEVOPST-3,E:\Upload-PM\att3.csv