1

I'm attempting to retrieve an image from my OneDrive via the Microsoft Graph API. I made sure to have all the necessary permissions to do so. This has worked in the past, but now it's returning error code 0. Here's my GET request:

$RequestHeader = @{
    "Authorization" = "Bearer $authToken"
    "Content-Type" = "image/jpeg"
}

$OneDriveUrl = "https://graph.microsoft.com/v1.0/drives/[drive-url]/items/[image-onedriveid]/content"

Invoke-RestMethod -Uri $OneDriveUrl -Method Get -Headers $RequestHeader -OutFile "newpicture.jpeg"

This should retrieve the picture into the current folder and name it "newpicture.jpeg".
I know for a fact that this has worked before because on the 1st of April I ran the same exact code (although with a different picture id) on the same drive and it retrieved a picture:

earlier-run

Has Microsoft been playing around with the OneDrive graph API? I recall that the "/content" at the end was not in the relevant documentation for this specific case. I believe I found that on a Stack Overflow thread about something similar, although it was working as intended.
Is there any way around this? If I remove the "/content" at the end I do received general information about that item, but at that point I don't need the relevant information, only the picture itself.

Am I missing something? Does anyone know a way around this? Thank you!

1

I think the endpoint must have had some trouble. It's working as intended now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.