Search code examples
azuremarkdown

Azure Rest APi get image attachment


I have a markdown file that contain a lot of element on an Azure project with some images in it that i created by doing request on the rest APi to get all the Workitem

And i want to parse the whole file to get all the image in order to download them all or to put them in a pdf file. But when i parse the image and try to display them i only have the alt="image.png"

For me the issue come from the fact that azure want to keep the image private: When i open my md file in vscode the image dont load but in azure they load if i put the same md as a wiki.

So what i want to know is if it's possible to get all the image contained in azure:

If yes do i need to change my PAT authorization in order to get the attachment or creating a new request is enough to get all the image based on the link that i have: https://dev.azure.com/company/smth/_apis/wit/attachments/wit_id?fileName=image.png


Solution

  • I found a way to do it properly.

    The image_url was in the body of the workitem, request_session in a request that was authentified with my PAT.

    
                img_data = request_session.get(image_url).content
                img_name = "test.png"
                with open(img_name, "wb") as handler:
                    handler.write(img_data)