How do I call create permissions on Google Drive API via Delphi - rest

I'm trying to use Delphi to call Google Drive Permissions API to create a permission on a team drive. All goes well with the setting on the Google Try It section, but my Delphi code isn't working.
reqPermissions.Body.Add('{role: "organizer",type: "user",emailAddress: "it_admin#mycompany.com"}');
I've tried supplying the type field as a parameter in the Request component, but this also doesn't work. Driving me nuts at the mo, so any help much appreciated.
I always get the following response:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "The permission type field is required.",
"locationType": "other",
"location": "permission.type"
}
],
"code": 400,
"message": "The permission type field is required."
}
}

Related

CMS Strapi any requst Forbidden Error 403

Trying to get data from strapi. I read the instructions
Execute a GET request on the restaurant collection type in order to fetch all your restaurants.
**Be sure that you activated the find permission for the restaurant collection type**
import axios from 'axios';
axios.get('http://localhost:1337/api/restaurants').then(response => {
console.log(response);
});
i create new type "restaurant" in "Content-type builder" and add fields, in "Content manager" created entities of this type. But my answer
{
"data": null,
"error": {
"status": 403,
"name": "ForbiddenError",
"message": "Forbidden",
"details": {}
}
}
I spent a lot of time searching for an answer, but I never found where to activate the find permission. Where is this option?
Do I need to configure JWT validation for that?

How to make a basic HTTP request with API key in Google Translate API v2?

I want to make a translation with Google Translate API v2 with a basic HTTP request. I get an API key from the console but I can't find out how to use arguments to make the translation.
Note: I want it to autodetect the source language and I only want to choose the target language.
This is the URL that I tried to use:
https://translation.googleapis.com/language/translate/v2/detect?fields=detections&key=BIzaSyA8uHGnsA8ICcBWWJcxhqVePGFMq0L4u0g&q=grapes&target=es
It returns this:
{
"error": {
"code": 400,
"message": "Request contains an invalid argument.",
"errors": [
{
"message": "Request contains an invalid argument.",
"domain": "global",
"reason": "badRequest"
}
],
"status": "INVALID_ARGUMENT"
}
}
See the documentation.
The authentication token goes in the Authorization request header, not the query string.

Tried to get facebook event

https://graph.facebook.com/895895040502397/events/attending/?fields=id,name,description,place,timezone,start_time,cover&offset=0&limit=2000&access_token=xxxxxxx&since=&until=2997993600
With this url I am getting below error.
{
"error": {
"message": "(#100) Tried accessing nonexisting field (fql) on node type (User)",
"type": "OAuthException",
"code": 100
}
}
Any idea how I can fix it.
.../895895040502397/attending...
Remove "events", the ID is already the ID of a specific event.
You can get event like this.
https://graph.facebook.com/895895040502397/attending/.....
Also Use CURL PHP.

Google Container Engine REST API Authorization

As mentioned here I created API key for using cluster operations.
For example for this query:
https://www.googleapis.com/container/v1beta1/projects/PROJECT_ID/clusters
And as mentioned
After you have an API key, your application can append the query
parameter key=yourAPIKey to all request URLs.
I added it to url:
https://www.googleapis.com/container/v1beta1/projects/PROJECT_ID/clusters?key=my_key
But i have error:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Login Required",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Login Required"
}
}
I even tried to add key to Authorization part of header...and had this error:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "authError",
"message": "Invalid Credentials",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Invalid Credentials"
}
}
Where is problem? Or did i something wrong?
According to the Google help documentation for API Keys (emphasis added):
An API key (either a server key or a browser key) is a unique
identifier that you generate using the Developers Console. Using an
API key does not require user action or consent. API keys do not grant
access to any account information, and are not used for
authorization.
Furthermore, it says that they can be used to access data that is public or owned by a Google service. The Google Container Clusters (GKE) data is neither of these. I'm not sure why the documentation suggests using an API key, but I know that OAuth works so if you can use that instead you should be able to get the REST API working.

Getting 200 OK abd 400 bad request on the same request from Google Drive REST API

My Google Drive app checks on start if its settings files(the files are all on Drive) has changed. Thus on every start sends a files.list request to the Google Drive API to get the files metadata. The app has been used for more then 4 months with no suspicious beahaviour from this request. But the last few days a strange thing is happening. The problem is that from time to time(every 1 out of 10-20 starts) the request gets this response
{
"error": {
"errors": [
{
"domain": "global",
"reason": "invalid",
"message": "Invalid Value",
"locationType": "parameter",
"location": "q"
}
],
"code": 400,
"message": "Invalid Value"
}
In all other cases the request gets an adequate response(200 OK mostly :)).
This is very strange because every time the request is the same and the query string( the q parameter) of course is the same i.e.
GET https://www.googleapis.com/drive/v2/files?corpus=DEFAULT&q=(title%3D'%5BClosed+Captions%5D.profile'+or+title%3D'Profiles'+or+title%3D'%5BGeneral%5D.profile'+or+title%3D'%5BTeletext%5D.profile'+or+title%3D'ezt5RoamingSettings.ini'+or+title%3D'ezt5ProjectSettings.ini'+or+title%3D'Project+Templates'+or+title%3D'ezt5IOPresets.ini'+or+title%3D'dicAutoCorrect.xml'+or+title%3D'dicShortForms.xml'+or+title%3D'dicDictionaries.xml')+and+trashed%3Dfalse&fields=items(fileSize%2C+id%2C+title%2C+modifiedDate%2C+md5Checksum%2C+parents(id%2C+isRoot))&key={MY_API_KEY}
Any ideas why is this happening will be much appreciated...