Google Drive Rest Api Files export limitation - rest

I use rest api "https://www.googleapis.com/drive/v3/files/fileId/export" "reference page" to get google Doc
I have document size ~ 5 MB when i try to get the file i had the json error :
{
"error": {
"errors": [
{
"domain": "global",
"reason": "exportSizeLimitExceeded",
"message": "This file is too large to be exported."
}
],
"code": 403,
"message": "This file is too large to be exported."
}
}
Is there any way to fix this error?

Instead of using this export endpoint you can request exportLinks field in the Files: list:
curl \
'https://www.googleapis.com/drive/v3/files/[FILE_ID]?fields=exportLinks' \
--header 'Authorization: Bearer [ACCESS_TOKEN]' \
--header 'Accept: application/json'
That will return something like this (these are links I got for a Google Slides presentation):
{
"exportLinks": {
"application/vnd.oasis.opendocument.presentation": "https://docs.google.com/feeds/download/presentations/Export?id=[FILE_ID]&exportFormat=odp",
"application/pdf": "https://docs.google.com/feeds/download/presentations/Export?id=[FILE_ID]&exportFormat=pdf",
"application/vnd.openxmlformats-officedocument.presentationml.presentation": "https://docs.google.com/feeds/download/presentations/Export?id=[FILE_ID]&exportFormat=pptx",
"text/plain": "https://docs.google.com/feeds/download/presentations/Export?id=[FILE_ID]&exportFormat=txt"
}
}
And those urls don't have such a hard size limit (I was able to get out ~50mb PDFs)

As stated in the error message there is a limit to how big of a file the API can export. There is really nothing you can do to fix that your going to have to do it with smaller files.
{
"error": {
"errors": [
{
"domain": "global",
"reason": "exportSizeLimitExceeded",
"message": "This file is too large to be exported."
}
],
"code": 403,
"message": "This file is too large to be exported."
}
}

Related

PUT k8s deployment returns 404

According to the Replacement section of Kubernetes API reference v1.24 I should be able to create a deployment with a PUT /apis/apps/v1/namespaces/{namespace}/deployments/{name} HTTP request. The success response here is 201 Created. However, when I try the following, I get a 404 Not Found which is of course correct but unwanted: PUT requests should be treated as Create statements if the resource does not yet exist as documented. Updating a deployment does work (and returns the expected 200 OK HTTP response). Is there any documentation regarding this? Or is the request somehow incorrect? Ty.
➜ ~ curl --request PUT \
--url http://localhost:8080/apis/apps/v1/namespaces/ns/deployments/nginx-deployment \
--header 'content-type: application/json' \
--data '{
"apiVersion":"apps/v1",
"kind":"Deployment",
"metadata":{
"name":"nginx-deployment",
"labels":{
"app":"nginx"
}
},
"spec": {
"replicas" : 3,
"selector": {
"matchLabels" : {
"app":"nginx"
}
},
"template" : {
"metadata" : {
"labels" : {
"app":"nginx"
}
},
"spec":{
"containers":[
{
"name":"ngnix",
"image":"nginx:1.7.9",
"ports":[
{
"containerPort": 80
}
]
}
]
}
}
}
}'
{
"kind": "Status",
"apiVersion": "v1",
"metadata": {},
"status": "Failure",
"message": "deployments.apps \"nginx-deployment\" not found",
"reason": "NotFound",
"details": {
"name": "nginx-deployment",
"group": "apps",
"kind": "deployments"
},
"code": 404
}%
According to the documentation you provided,
PUT /apis/apps/v1/namespaces/{namespace}/deployments/{name}
is meant to "replace the specified Deployment", while a Deployment is created with a POST:
create a Deployment
HTTP Request
POST /apis/apps/v1/namespaces/{namespace}/deployments
You are correct that the documentation also states:
For PUT requests, Kubernetes internally classifies these as either create or update based on the state of the existing object
so there seems to be a contradiction, but the Deployment API spec states that POST should be used to create a deployment and PUT to update it.

How to access firebase bucket in google cloud API

I am working on google Speech to Text API. Where i am recording audio in iphone and saving it on Firebase bucket. than when i call api i get error 403.
curl -s -X POST -H "Content-Type: application/json" --data-binary #request.json \
"https://speech.googleapis.com/v1/speech:recognize?key=${API_KEY}"
content of request.json
{
"config": {
"encoding":"FLAC",
"languageCode": "en-US"
},
"audio": {
"uri":"gs://audiosave-9ec73.appspot.com/AudioFiles/audio.flac"
}
}
and response i am getting
{ "error": {
"code": 403,
"message": "Anonymous caller does not have storage.objects.get access to audiosave-9ec73.appspot.com/AudioFiles/audio.flac.",
"status": "PERMISSION_DENIED" } }

Unable to get CPM data from Youtube Analytics account

I'm unable to get CPM data from my Youtube reports:
I'm getting:
{
"error": {
"code": 403,
"message": "Forbidden",
"errors": [
{
"message": "Forbidden",
"domain": "global",
"reason": "forbidden"
}
]
}
}
I don't even know where to begin to debug this, and I haven't found anything online.
I'm just trying to curl the endpoint, mirroring this: HERE
Notice that once you finish the oauth process, User will see
"You do not have permission to execute this method." and the 403
Also, Notice if you remove 'CPM' from the list of metrics, this will work.
Example:
curl --header "Authorization: Bearer _____access_token____" -e "https://developers.google.com" https://content-youtubeanalytics.googleapis.com/v2/reports\?endDate\=2014-06-30\&ids\=channel%3D%3DMINE\&metrics\=cpm\&startDate\=2014-05-01\&key\=_____api_key____
I'm getting the refresh token via:
<script>
var auth2;
var SCOPE = ['https://www.googleapis.com/auth/adwords',
'https://www.googleapis.com/auth/yt-analytics.readonly',
'https://www.googleapis.com/auth/youtube',
'https://www.googleapis.com/auth/yt-analytics-monetary.readonly',
'https://www.googleapis.com/auth/youtubepartner-channel-audit',
'https://www.googleapis.com/auth/youtubepartner',
'https://www.googleapis.com/auth/youtube.readonly',
] ;
function initClient() {
auth2 = gapi.auth2.init({
'clientId': 'my-client-id',
'scope': SCOPE.join(' '),
'prompt': 'consent',
})
}
function handleClientLoad() {
gapi.load('auth2', initClient);
}
</script>
<script async defer src="https://apis.google.com/js/api.js"
onload="this.onload=function(){};handleClientLoad()"
onreadystatechange="if (this.readyState === 'complete') this.onload()">
</script>
the access token I'm using is from the refresh token via:
https://www.googleapis.com/oauth2/v4/token?client_id={my_client_id}&client_secret={my_client_secret}&refresh_token={my_refresh_token}&grant_type=refresh_token
and I'm getting:
{
"access_token": "ya29.GlvyBZVPpC.....",
"token_type": "Bearer",
"expires_in": 3600,
"scope": "https://www.googleapis.com/auth/youtubepartner https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/adwords https://www.googleapis.com/auth/youtube https://www.googleapis.com/auth/plus.me https://www.googleapis.com/auth/youtube.readonly https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/yt-analytics.readonly https://www.googleapis.com/auth/yt-analytics-monetary.readonly",
"id_token": "eyJhbGciOiJSUz...."
}
I don't believe it's an issue with my scopes as I am not getting a 403 like:
{
"error": {
"code": 403,
"message": "Request had insufficient authentication scopes.",
"errors": [
{
"message": "Request had insufficient authentication scopes.",
"domain": "global",
"reason": "forbidden"
}
],
"status": "PERMISSION_DENIED"
}
}

Google URL Shortner cURL returns error

I have a API Key and tried to use it for shortening URL. If I shorten google.com then I get shorten url
curl https://www.googleapis.com/urlshortener/v1/url?key=MYKEY -H 'Content-Type: application/json' -d '{"longUrl": "www.google.com"}'
{
"kind": "urlshortener#url",
"id": "shorten url",
"longUrl": "http://www.google.com/"
}
But if I use other URLs like yahoo.com then returns the error
curl https://www.googleapis.com/urlshortener/v1/url?key=MYKEY -H 'Content-Type: application/json' -d '{"longUrl": "www.yahoo.com"}'
{
"error": {
"errors": [
{
"domain": "global",
"reason": "forbidden",
"message": "Forbidden"
}
],
"code": 403,
"message": "Forbidden"
}
}
Not sure why?

Google cloud storage client api not working for patch

I tried updating header of an object by using API explorer (as well as client library) by giving metadata object as header keys and values.
I only received error respond
{
error": {
"errors": [
{
"domain": "global",
"reason": "invalid",
"message": "Invalid argument."
}
],
"code": 400,
"message": "Invalid argument."
}
}
The request is:
PATCH https://www.googleapis.com/storage/v1beta2/b/mbi-figure/o/infovilla_paypal.png?key={YOUR_API_KEY}
Content-Type: application/json
Authorization: Bearer ya29
X-JavaScript-User-Agent: Google APIs Explorer
{
"metadata": {
"title": "Kyaw"
}
}
You've run into a bug with PATCH that is being worked on. Fortunately, there's a workaround. Adding a "projection=full" parameter to the URL should fix your problem.