I want to limit the capabilities of a file in personal Google Drive. When I use the API explorer Google Drive v3 API with the following request:
POST https://www.googleapis.com/drive/v3/files?key={YOUR_API_KEY}
{
"capabilities": {
"canCopy": false
},
"name": "testfile"
}
I get the following response:
403
- Show headers -
{
"error": {
"errors": [
{
"domain": "global",
"reason": "fieldNotWritable",
"message": "The resource body includes fields which are not directly writable."
}
],
"code": 403,
"message": "The resource body includes fields which are not directly writable."
}
}
Which is the same response that I get when trying to update a file with:
PATCH https://www.googleapis.com/drive/v3/files/FileIdHere?key={YOUR_API_KEY}
{
"capabilities": {
"canCopy": false
}
}
It seems that there are no methods to accomplish this or has anyone a workaround?
If you check file resource you will notice that some fields are writeable while others are not.
The message you are seeing is because the field you are trying to set is not writeable this means you can not change it from the API
Related
I want to get all my groups but I am not an admin
I know how to fetch groups if I am admin. But if not - I don't understand. Also I can see its via website
My steps:
I do auth with Google and with scope
[
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/groups",
]
I fetch groups by GET. Url: "https://admin.googleapis.com/admin/directory/v1/groups?domain=konstructly.com"
I get the next problem:
{
"error": {
"code": 403,
"message": "Not Authorized to access this resource/api",
"errors": [
{
"message": "Not Authorized to access this resource/api",
"domain": "global",
"reason": "forbidden"
}
]
}
}
My question
How can I get my Google Groups via Google API?
I tried:
Auth with scope
[
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/groups",
]
GET "https://admin.googleapis.com/admin/directory/v1/groups?domain=konstructly.com"
Expectation:
List of my groups
Actual result:
{
"error": {
"code": 403,
"message": "Not Authorized to access this resource/api",
"errors": [
{
"message": "Not Authorized to access this resource/api",
"domain": "global",
"reason": "forbidden"
}
]
}
}
Instead of using the Google Workspace Admin SDK, use the Groups Service from Google Apps Script, more specifically GroupsApp.getGroups()
According to https://developers.google.com/drive/api/v3/reference/changes/watch,
you need an https address to make it works if you need to watch over a change of resources.
I've configured the domain successfully by going to Google Cloud Console > Domain Verification > Add Domain.
Then I use Postman to make a call to test it:
https://www.googleapis.com/drive/v3/changes/watch?pageToken=nextPageToken
{
// "kind": "api#channel",
"id": "1234231",
"expiration": 1656402233000,
"type": "webhook",
"payload": true,
"address": "https://mrnoc.blogspot.com",
"params": {
"pageToken": "nextPageToken"
}
}
However, it failed and generated this error message:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "push.webhookUrlUnauthorized",
"message": "Unauthorized WebHook callback channel: https://mrnoc.blogspot.com"
}
],
"code": 401,
"message": "Unauthorized WebHook callback channel: https://mrnoc.blogspot.com"
}
}
I have no idea how it doesn't work, I've tried to look around but it a dead end as it seems like I've configured everything properly.
Please help if you know what might stop it from working.
Thank you
I'm using Google Geolocation API to convert a single Cell Tower data to location data. The request is made by a Windows service. Typically it's:
{
"considerIp": "false",
"cellTowers":
[
{
"cellId": 60711,
"locationAreaCode": 856,
"mobileCountryCode": 234,
"mobileNetworkCode": 15
}
]
}
Very often (about 80% of my requests) the response is "Error 404 geolocation not found":
{
"error": {
"code": 404,
"message": "Not Found",
"errors": [
{
"message": "Not Found",
"domain": "geolocation",
"reason": "notFound"
}
]
}
}
For this reason I was forced to use a similar service provided by Unwiredlabs, that successfully answer to 95% of my requests.
Is it possible that Google cannot resolve 80% of my requests? I don't think so, but I can't understand where I'm wrong.
For testing purpose cells.csv contains Tower Cells localized by Unwiredlabs, but only ~20% localizied by Google Geolocation API
I'm trying to access oneDrive via Graph api, and when I hit the api, I get User's mysite not found.
GET https://graph.microsoft.com/beta/me/drive
{
"error": {
"code": "ResourceNotFound",
"message": "User's mysite not found.",
"innerError": {
"request-id": "13eb583d-c29a-42af-8868-bae06d554538",
"date": "2018-05-18T06:06:55"
}
}
}
So, looking out for the solution, I saw an issue where they said to get OneDrive for Business' location, But this returns UnauthorizedAccessException
GET https://graph.microsoft.com/beta/me?select=mySite
{
"error": {
"code": "-2147024891, System.UnauthorizedAccessException",
"message":
"Access denied. You do not have permission to perform this action or access this resource.",
"innerError": {
"request-id": "3489894e-faa0-42c6-9f3b-e76c4708ce15",
"date": "2018-05-18T06:10:00"
}
}
}
And when I hit for /me endpoint, there I see an empty array for provisionedPlans.
GET https://graph.microsoft.com/beta/me
{
"#odata.context": "https://graph.microsoft.com/beta/$metadata#users/$entity",
"id": "7e8397a6-b299-34a2-af06-d3487t5b5174",
//...
"onPremisesProvisioningErrors": [],
"provisionedPlans": []
}
My access token is
eyJ0eXAiOiJKV1QiLCJub25jZSI6IkFRQUJBQUFBQUFEWDhHQ2k2SnM2U0s4MlRzRDJQYjdySGc5dDJ4SmxkODFMRURNY1FuN3pMYVgyektLaDR2SF9FSFltd1JaQ3Y5TU55VDJOR250VmlDQVFmTXpiTWxoYkZWQ19nSEdtaWhfWlJfcVlpaGRyMHlBQSIsImFsZyI6IlJTMjU2IiwieDV0IjoiaUJqTDFSY3F6aGl5NGZweEl4ZFpxb2hNMllrIiwia2lkIjoiaUJqTDFSY3F6aGl5NGZweEl4ZFpxb2hNMllrIn0.eyJhdWQiOiJodHRwczovL2dyYXBoLm1pY3Jvc29mdC5jb20vIiwiaXNzIjoiaHR0cHM6Ly9zdHMud2luZG93cy5uZXQvM2FjMThiOGMtNjY4ZC00NzBhLWJhMDctYWU0MjdlMTkwZGEyLyIsImlhdCI6MTUyNzE0MDg2MCwibmJmIjoxNTI3MTQwODYwLCJleHAiOjE1MjcxNDQ3NjAsImFjciI6IjEiLCJhaW8iOiJBVFFBeS84SEFBQUE4UitBY2U4bnpGU0JXRGg4NUFHUWE1VXowT05yZEZ5VzhXQnYvZ1BnVE1nMWx4MnNibkZSbUdrbHVsNVhiME5SIiwiYWx0c2VjaWQiOiI1OjoxMDAzMDAwMDk3NURDNEFCIiwiYW1yIjpbInB3ZCJdLCJhcHBfZGlzcGxheW5hbWUiOiJJbnRlbGlOb3Rpb24gRGVtbyIsImFwcGlkIjoiYWU0OTY3MGItNmIwYi00NjgxLWE5OTAtNmZmZWQ1NTFiMjMwIiwiYXBwaWRhY3IiOiIxIiwiZW1haWwiOiJrb21hbC5oZW5kcmVAc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66NApYR__YDGzO4HsTk_MA9OSQCHcw5mOaOeRKZmRTDPIokyYpeNgXBK9FmZivBg
Can't figure out that it is a access problem or provisioning problem. Can anyone suggest what's going wrong here.
I want to use Google Drive from Postman, and when I tried to hit the API I am geting an error.
URL:
https://www.googleapis.com/drive/v3/files/1Iwvqcx073GhEU9eRD4vPihXoj2AV63LEyLZwu6i0jTQ?alt=media
I am getting:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "fileNotDownloadable",
"message": "Only files with binary content can be downloaded. Use Export with Google Docs files.",
"locationType": "parameter",
"location": "alt"
}enter code here
],
"code": 403,
"message": "Only files with binary content can be downloaded. Use Export with Google Docs files."
}
}
you need to add responseType: 'blob' if you are trying to get a pdf file
https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Sending_and_Receiving_Binary_Data
Check this link for more info on how to handle file content download