I’m trying to get the content of a file as a pdf from Onedrive, however when getting the File via MSGraphClient, it just returns an error in the browser.
The error in the browser is :
Access to fetch at 'https://someurl.svc.ms/transform/PDF?somelongpathtofile' (redirected from 'https://graph.microsoft.com/v1.0/me/drive/root:/tiles/testfile.docx:/content?format=PDF') from origin 'null' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
I can’t catch the error or evaluate it in any way in the code, my actual response is just a “Failed to fetch”. I tried the same call using the AadHttpClient and setting the mode to “no-cors” but that doesn’t return any useful information either.
Is there any way of letting the redirect pass through or catching the redirect via msgraphclient or the aadhttpclient, all i need is the new URL so i can make a GET Request to it?
Thank you for your help.