0
votes

What I have:

url = 'https://dev.azure.com/whatthefk-logistics/LQS/_apis/wit/workitem/666?api-version=6.0' user_name = 'Quake Tarantino' token = 'xi2q7ufkko3h4ixt3xi2q7ufkko3h4ixt3xi2q7ufkko3h4ixt3'

What I need: download all attachments and save them to the defined location

Thanks everyone for help

1

1 Answers

0
votes

I am not proud of this:

def  DownloadAttachments():
   url_get_m = 'https://dev.azure.com/macs/Logr/_apis/wit/workitems/666?$expand=all&api-version=5.0'

   r = requests.get(url_get_m, auth=(user_name_m, token_m))
   res = r.json()

   for item in res['relations']:
       if item['rel'] == 'AttachedFile':
           with open(item['attributes']['name'], "ab") as f:
               f.write(requests.get(item['url']).content)