Skip to content

Getting "kiota_http._exceptions.RedirectError: Too many redirects. []" Error #504

Closed
@Luki2003

Description

@Luki2003

I am trying to download all pptx files from a OneDrive folder as pdf files. To do this, all pptx files are first saved with file name and id in a dictionary. Then the contents are downloaded via a for loop. This works up to the 5th element. From the 6th element I get the error: "kiota_http._exceptions.RedirectError: Too many redirects. []"

Here is my code:

for file_name, file_id in files.items():
      loop.run_until_complete(convert_and_download_file_content(client, drive_id, file_id, file_name))
async def convert_and_download_file_content(_graph_client: GraphServiceClient, _drive_id: str, _file_id: str, _filename: str) -> None:
    content: bytes | None = await _graph_client.drives.by_drive_id('drive-id').items.by_drive_item_id('driveItem-id').content.with_url(f'https://graph.microsoft.com/v1.0/drives/{_drive_id}/items/{_file_id}/content?format=pdf').get()
    if content is None:
        raise ValueError("Content is None!")

    with open(f"./pdf-files/{_filename}", "wb") as file:
        file.write(content)

    print(f"Downloaded {_filename}!")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions