I have a function that makes shared files it works perfectly for normal files but when I need to create a public folder it can`t. In Google documentation they are same operations
def GetLinkToFile(file_id,file2):
url = 'https://www.googleapis.com/drive/v3/files/' + file_id + '/permissions?supportsAllDrives=true'
headers = {'Authorization': 'Bearer ' + access_token, 'Content-Type': 'application/json'}
payload = {'type': 'anyone', 'role': 'reader'}
res = requests.post(url, data=payload, headers=headers)
link = file2['alternateLink']
pyperclip.copy(link)
This function returns error 400 Invalid request when used with folder and works fine when used with file
I think that the request for your showing script is required to be modified. So, I would like to propose the following modification.
res = requests.post(url, data=payload, headers=headers)
res = requests.post(url, data=json.dumps(payload), headers=headers)
import json
.