Google Slides API invalid presentations id - php

I'm trying to create some slides with the Slides API but I started getting this error Invalid presentation.presentationId: The id is invalid.
I tried to create it through the API reference without success as shown in the image:
Reference request and error image
Is there any limitation on the presentationId or some other required fields I should pass?
This is the exception I get:
{
"error": {
"code": 400,
"message": "Invalid presentation.presentationId: The id is
invalid.",
"errors": [
{
"message": "Invalid presentation.presentationId: The id is invalid.",
"domain": "global",
"reason": "badRequest"
}
],
"status": "INVALID_ARGUMENT"
}
}

You want to create new Slide using Method: presentations.create. If my understanding is correct, how about this?
In your case, please try it using the request body with title and without presentationId as follows.
Note :
At this request body, a new Slide with the filename of "Teste123" is created to the root.
Reference :
Method: presentations.create
If I misunderstand your question, I'm sorry.

Dont specify a presentation ID -- just a title and the API call should work as you expect. The presentation ID will be generated by Slides for you.
Previously, Slides would ignore all presentation IDs passed in on create, but this behavior changed recently. See documentation for presentations.create

Related

Search for a file or folder from google drive api via the name of the file/folder?

I am trying to make a function that can search for a file/folder. If the file/folder exists then it will return the id else will return null from the drive in PHP, but every time I do this it shows that there is some error in q.
An error occurred: {
"error": {
"errors": [
{
"domain": "global",
"reason": "invalid",
"message": "Invalid Value",
"locationType": "parameter",
"location": "q"
}
],
"code": 400,
"message": "Invalid Value"
}
}
The query is:-
//testing-folder-of-api is the name of the folder
mimeType=application/vnd.google-apps.folder and name='testing-folder-of-api'
I also tried with changing it like:
mimeType!=application/vnd.google-apps.folder if not a file
name contains 'test.txt' and title='test.txt' for searching it by name.
The solution that I found was that to loop through all the files and check the name individually using a loop which took to much time.
Can someone plz show me how to do it. Please!!
Issue:
You should add single quotes around 'application/vnd.google-apps.folder', as mentioned at File-specific query terms:
mimeType: MIME type of the file. Surround with single quotes '.
Solution:
mimeType='application/vnd.google-apps.folder' and name='testing-folder-of-api'

How can I validate related fields in api platform?

I have question maybe someone could help me with. I tried to find answer, but no results.
Problem:
I have 2 entities Comment and Video, comment belong to video (many to one). When send creation request to /comments with video that no exists, I'm getting next error:
"type": "https://tools.ietf.org/html/rfc2616#section-10",
"title": "An error occurred",
"detail": "Item not found for resource \"App\\Entity\\Video\" with id \"2\".",
and status code 400.
I want change this behavior and receive next response:
{
"type": "https://tools.ietf.org/html/rfc2616#section-10",
"title": "An error occurred",
"detail": "Item not found for resource \"App\\Entity\\Video\" with id \"2\".",
"violations": [
{
"propertyPath": "video",
"message": "Item not found for resource \"App\\Entity\\Video\" with id \"2\".",
"code": "c1051bb4-d103-4f74-8988-acbcafc7fdc3"
}
]
}
and status 422.
Question:
How can I validate related fields?
I already tried create custom validator, but /vendor/api-platform/core/src/Serializer/AbstractItemNormalizer.php return error before my validation.
If you have any solutions for this, I'll really happy. Anyways thank you!
https://symfony.com/doc/current/reference/constraints/Valid.html may help : you just add the validator #Assert\Valid to check if the child exists

Create Local post on Google My Business Issue

Attempting to create Google My Business Local Post using My Business API and PHP.
A Local Post is created just fine EXCEPT when adding the mediaItem object to the post body.
Getting the error :
{
"error": {
"code": 400,
"message": "Request contains an invalid argument.",
"errors": [{
"message": "Request contains an invalid argument.",
"domain": "global",
"reason": "badRequest"
}],
"status": "INVALID_ARGUMENT"
}
}
Below is the post object with mediaItem that is being sent to localPosts->create
$new_post = new Google_Service_MyBusiness_LocalPost();
$new_post->setSummary('Hello World');
$new_post->setLanguageCode('en-US');
$media = new Google_Service_MyBusiness_MediaItem();
$media->setMediaFormat("PHOTO");
$media->setSourceUrl("https://www.webyhub.com/img/logo.png");
$new_post->setMedia($media);
You will need to do this on Postman to get the detail validation message as to why the image you used is invalid.
Try Advanced Rest Client (or Postman), make a POST request to https://mybusiness.googleapis.com/v4/accounts/{uuid}/locations/{uuid}/localPosts with
Header: Authorization: Bearer {access_token}.
Body Content Type: application/json
Body:
{
"summary":"test",
"topicType":"STANDARD",
"media":[{"mediaFormat": "PHOTO","sourceUrl": "https://example.com/files/test.jpg"}]
}
Also, Creating Post with video uploading is not currently available. I dont know why but I am also stuck on this matter.

YouTube Content ID API with Service Account returns Forbidden error

I've created a service account for use with the YouTube Content ID API, I'm following the steps under Set up your service account on:
https://developers.google.com/youtube/partner/guides/oauth2_for_service_accounts
The steps seem to be a bit outdated, but I'm managed to create a service account and I've got the email address. I didn't know if I needed to assign a Role so I didn't.
I visited the Content ID users page and invited the service account user:
The problem is I get the error the request could not be completed, but when I refresh the page, the user appears to be added successfully.
Well, when I'm making requests using this service account, I'm getting forbidden errors. For example the below error is when I'm trying to get a list of claims.
{
"error": {
"errors": [
{
"domain": "global",
"reason": "forbidden",
"message": "Forbidden"
}
],
"code": 403,
"message": "Forbidden"
}
}
But some requests work, like listing/inserting labels, listing content owners.
All the permissions are assigned for the user so I'm not sure what the reason for the forbidden errors are.
Here's the PHP code:
$OAUTH2_KEY_FILE = 'key.json';
$client = new \Google_Client();
$client->setAuthConfig($OAUTH2_KEY_FILE);
$client->setScopes([\Google_Service_YouTubePartner::YOUTUBEPARTNER]);
$youtubePartner = new \Google_Service_YouTubePartner($client);
dd($youtubePartner->claims->listClaims([
'onBehalfOfContentOwner' => 'XXX'
]));

PHP Google Play Subscription API

I am trying to get Google Play API subscription details using PHP and using following url to get purchase data :
https://www.googleapis.com/androidpublisher/v1/applications/[PACKAGE]/subscriptions/[SKU]/purchases/[PURCHASE_TOKEN]?access_token=[ACCESS_TOKEN]
I am getting the following error:
{
"error": {
"errors": [
{
"domain": "androidpublisher",
"reason": "developerDoesNotOwnApplication",
"message": "This developer account does not own the application."
}
],
"code": 401,
"message": "This developer account does not own the application."
}
}
Please help me sort out.
Just providing the URL does not help you get data of any application. How can you think so.? Isnt it insecure.? You have to get proper data by which you can at least prove ownership for the app..

Categories