Azure Rest Api。如何从工作项下载附件? Python

Azure Rest Api. How to download an attachment from the workitem? Python

我有:

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

我需要的: 下载所有附件并保存到指定位置

感谢大家的帮助

我不以此为荣:

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)