How can I create a new folder in google drive using python only if it doesn't exists? I am completely new to this google APIs and python.
(I have an access token for my account and I want to create folder using that.)
create folder
import json
import requests
headers = {"Authorization": "Bearer Token"}
data = {
"name": "name",
"mimeType": "application/vnd.google-apps.folder"
}
r = requests.post("https://www.googleapis.com/drive/v3/files",
headers=headers,data = data)
print(r.text)
Only file is getting created, not folder. How can I rectify the problem?
use get_folder_id which internally creates a folder if doesn't exists.
PS: This code is blindly copied from my work, if you have any difficulty in understanding, I can elaborate the answer.