The revisions representation no longer provides a revisions.downloadUrl nor does it provide the files.ID of the file it is a revision of. In order to download a revision I need both the files.ID and the revisions.ID
Am I missing something, or is it weird that the revisions representation doesn't have enough information in it to download the revision?
Alternative to be used for downloadUrl is revisions.get with ?alt=media. Here's the reference.
Also, per Listing and downloading individual revisions,
Once you get a list of a file's revisions, you can download the content of any revision by calling the revisions.get method with the parameter alt=media. Revisions for Google Docs, Sheets, and Slides can not be downloaded.
With this, try to get the list using Revisions: list which returns revision details in the response body with this sample structure:
{
"kind": "drive#revisionList",
"nextPageToken": string,
"revisions": [
{
"kind": "drive#revision",
"id": string,
"mimeType": string,
"modifiedTime": datetime,
"lastModifyingUser": {
"kind": "drive#user",
"displayName": string,
"emailAddress": string
},
"originalFilename": string,
"size": long
}
]
}
Related
I have access to a specific endpoint and i want to send several request to it at once but i am not 100% sure how to do that. I need to update several information related to different products so i need to specify the product within the endpoint, i mean, i.e:
If you access this particular endpoint: {{URL_API}}/products/ you will get all the products but i need to specify the product that i want to update:
{{URL_API}}/products/99RE345GT
Take a look at this, i want to send a JSON like this:
{
"sku": "99RE345GT",
"price": "56665.0000",
"status": 1,
"group_prices": [
{
"group": "CLASS A",
"price": 145198.794
},
{
"group": "CLASS B",
"price": 145198.794
},
{
"group": "CLASS C",
"price": 145198.794
}
]
}
AND another one like this (both JSONs share the same structure BUT with different information):
{
"sku": "98PA345GT",
"price": "17534.0000",
"status": 1,
"group_prices": [
{
"group": "CLASS A",
"price": 145198.794
},
{
"group": "CLASS B",
"price": 145198.794
},
{
"group": "CLASS C",
"price": 145198.794
}
]
}
How can i do that?.I have already generated more than 200 JSONs for every product..
So, i have to update 200 products so i generated one JSON for every product, do you get me?
Following my example i would need to edit (somehow) the endpoint for every product and send a JSON, i.e:
since the first JSON has the SKU: 99RE345GT it should perform a http method: PUT over this enpoint:
{{URL_API}}/products/99RE345GT
Then, since the second JSON has the SKU: 98PA345GT it should perform a http method: PUT over this enpoint:
{{URL_API}}/products/98PA345GT
I have never done something like this before.. i read something about CSV + POSTMAN runner but i did not understand the way.
Can you help me?
EDIT:
NEW UPDATE, if i use GET it throws "200" but i have to perform a PUT method:
without having access to your API docs or any indication which information is changing, i've made the following assumptions:
the PUT endpoint requires the SKU id in the endpoint
price, status, class A price, class B price, class C price are variables that are changing
first up create your request like so... identifying the variables.
next create your CSV file, making sure to use field/column names that match the variables.
final step, open Collection Runner and click Select File. once you've selected your CSV file, the iterations field will update with the number of rows in the file.
from there you just run your request and Postman will iterate through your file updating the products using the info in your CSV file.
How can I export specific version of Google document?
I want to create an exact slice copy of user's gdrive.
The idea is
Get list of head revisions for all files in drive
Download or export every file with exact revision
But for google docs files I can't find an head revision field in /files/list/:
{
"id": "1Vsg1U58vXPCGqL2KFAT-cY9ckAIwWxQQ0-49HOPtHzI",
"name": "Spreadsheet-test-file-1",
"mimeType": "application/vnd.google-apps.spreadsheet",
"version": "844"
},
and when I list all revisions for this file, I get this:
{
"kind": "drive#revisionList",
"revisions": [
{
"kind": "drive#revision",
"id": "1",
"mimeType": "application/vnd.google-apps.spreadsheet",
"modifiedTime": "2017-07-04T07:21:24.849Z"
},
{
"kind": "drive#revision",
"id": "2",
"mimeType": "application/vnd.google-apps.spreadsheet",
"modifiedTime": "2017-07-04T07:21:24.852Z"
}
]
}
But when I try to download this revision, I get an error Only files with binary content can be downloaded. Use Export with Google Docs files.
I know that API docs says that Google docs can't be downloaded with revisions. But if so, I don't understand how to get the exact slice of the drive?
By the way, I am using the Go library for drive api.
I am using the Google Drive API. I can get a list of files with the drive.files.list API method. Here is the result of a call to this method:
{
"files": [
{
"id": "1yLJFT2bHhsz1WxJX29mD9DiNz0vLDlBvzJf5GJCcboI",
"mimeType": "application/vnd.google-apps.spreadsheet",
"parents": [
"0Bwy7SlKkxnwQRld6RWljU0Y4TG8"
]
},
{
"id": "0Bwy7SlKkxnwQVXdBRmlPMGNoTmM",
"mimeType": "application/vnd.google-apps.folder",
"parents": [
"0B4jAnSzS-VxlZW9RcDJheU5FYW8"
]
},
{
"id": "0Bwy7SlKkxnwQRld6RWljU0Y4TG8",
"mimeType": "application/vnd.google-apps.folder",
"parents": [
"0Bwy7SlKkxnwQQndiQnYxbUF4SjQ"
]
}]
}
When I request individual files using the drive.files.get API call, I would expect to get the same results as shown in the list above. I do when I request the first and third file listed. For example:
GET https://www.googleapis.com/drive/v3/files/0Bwy7SlKkxnwQRld6RWljU0Y4TG8?supportsTeamDrives=true&fields=id%2CmimeType%2Cparents
Result:
{
"id": "0Bwy7SlKkxnwQRld6RWljU0Y4TG8",
"mimeType": "application/vnd.google-apps.folder",
"parents": [
"0Bwy7SlKkxnwQQndiQnYxbUF4SjQ"
]
}
This is identical to what is shown in the list. But for some reason when I request the second file in the list, the parents list is missing from the result:
GET https://www.googleapis.com/drive/v3/files/0Bwy7SlKkxnwQVXdBRmlPMGNoTmM?supportsTeamDrives=true&fields=id%2CmimeType%2Cparents
Result:
{
"id": "0Bwy7SlKkxnwQVXdBRmlPMGNoTmM",
"mimeType": "application/vnd.google-apps.folder"
}
No parents array. Can anyone explain this behavior? I assumed all files should have a parent.
If you haven't done yet, you may want to check if you have an access to the parent of your second file. As stated in Enabling Team Drives:
A parent does not appear in the parents list if the requesting user is a not a member of the Team Drive and does not have access to the parent.
In Behavioral differences, fields related to permissions and ownership are populated differently.
I'm building a front end using WP JSON, and I need (among other things) the name of the author of each post.
In V1, this was easy - here's a fragment of a typical post object from calling http://example.com/wp-json/posts/1:
{
"ID": 1,
"title": "Hello world!",
"status": "publish",
"type": "post",
"author": {
"ID": 1,
"name": "admin",
"slug": "admin",
"URL": "",
"avatar": "http:\/\/0.gravatar.com\/avatar\/c57c8945079831fa3c19caef02e44614&d=404&r=G",
"meta": {
"links": {
"self": "http:\/\/example.com\/wp-json\/users\/1",
"archives": "http:\/\/example.com\/wp-json\/users\/1\/posts"
}
}
},
But in V2, for author, all we get back is the ID (an integer). Passing this back to the API, we get a list of every article an author has written - but how can I get the author's information - their name, avatar, etc.?
PS: boy the V2 documentation is sparse...V1 was much better...
Append the query parameter _embed in your API URL
Embedding is triggered by setting the _embed query parameter on the request. This will then include embedded resources under the _embedded key adjacent to the _links key in JSON file... as showed in http://v2.wp-api.org/reference/links.html
Examples:
http://demo.wp-api.org/wp-json/wp/v2/posts?_embed
http://demo.wp-api.org/wp-json/wp/v2/posts?filter%5Bposts_per_page%5D=10&page=1&_embed
Getting Author Name from JSON, and showing:
{{postItem._embedded.author[0].name}}
Getting Featured Image:
{{postItem._embedded['wp:featuredmedia'][0].source_url}}
Categories:
{{postItem._embedded['wp:term'][0][0].slug}}
{{postItem._embedded['wp:term'][0][1].slug}}
{{postItem._embedded['wp:term'][0][2].slug}}
{{postItem._embedded['wp:term'][0][3].slug}}
...
and Tags:
{{postItem._embedded['wp:term'][1][1].slug}}
{{postItem._embedded['wp:term'][1][2].slug}}
...
I think what you want is /wp-json/wp/v2/users/1
You should also find the direct url at _links > author > href
Is there a way to fetch the complete folder path of a file given the file Id using the Box API?
From the API documentation it is clear that we can use the Parent Folder ID to recursively fetch folder names until the root is reached, however this would result in a lot of REST API calls depending on the number of parent folders.
The path_collection property of the file object contains "the path of folders to this item, starting at the root." This information can be fetched in a single API request using only the file ID. See the documentation for a detailed example, a portion of which is shown below. The total_count field indicates the depth of the tree for that file, and the entries field contains information about each folder in the tree. It's my understanding that the entries are returned in order.
"path_collection": {
"total_count": 2,
"entries": [
{
"type": "folder",
"id": "0",
"sequence_id": null,
"etag": null,
"name": "All Files"
},
{
"type": "folder",
"id": "11446498",
"sequence_id": "1",
"etag": "1",
"name": "Pictures"
}
]
},
private String getFullPath(BoxFile.Info info)
{
List<BoxFolder> filePathList = info.getPathCollection();
StringBuffer fullPathStringBuffer = new StringBuffer("");
for (BoxFolder pf : filePathList)
{
fullPathStringBuffer.append("/").append(pf.getInfo().getName());
}
System.out.println(fullPathStringBuffer.toString());
return fullPathStringBuffer.toString();
}