Hi @Juanjo ,
As per documentation 504 - Gateway Timeout: The server, while acting as a proxy, did not receive a timely response from the upstream server it needed to access in attempting to complete the request.
504 Gateway Timeout generally happens when you try to retrieve large amounts of data in single API call and request gets timed out at the server side before sending the response.
Try to limit the amount of data retrieved from Microsoft Graph GET /drives/{drive-id}/root:/{path-relative-to-root}:/children?$expand=thumbnails
by using $top
and $select
to improve the performance of your Graph API call.
Additional references:
driveitem_list_children
driveitem-list-thumbnails
throttling
Hope this helps.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".