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.
Related
I am building a tool automatically scan a local folder and upload files to BIM360 Docs, with 2 legged authentification, so far files can already uploaded to BIM360 Docs using Forge Data Management API however the "updated by" field is empty. what i want to accomplish is load the current login user and set the current user's name as updated by.
I cannot find anywhere i can use from Forge API to set the "updated by", can anyone suggest?
Thanks a lot.
When you post/patch an item/version there are two fields you can specify that suit your needs - lastModifiedUserId and lastModifiedUserName:
"attributes": {
"mimeType": "appplication/pdf",
"displayName": "version-test.pdf",
"name": "version-test.pdf",
"extension": {
"data": {
"tempUrn": null,
"storageType": "OSS",
"properties": {},
"storageUrn": "urn:adsk.objects:os.object:wip.dm.prod/3c8f6bbc-fe5c-4815-a92e-8b8635e7b1cb.pdf"
},
"version": "1.0",
"type": "versions:autodesk.bim360:FileVersions",
"schema": {
"href": "/schema/v1/versions/versions%3Aautodesk.bim360%3AFileVersions-1.0"
}
},
"createUserName": "John Doe",
"createTime": "2016-04-01T11:09:03.000Z",
"createUserId": "BW9RM76WZBGL",
"lastModifiedUserName": "John Doe",
"lastModifiedUserId": "BW9RM76WZBGL",
"versionNumber": 2,
"lastModifiedTime": "2016-04-01T11:11:18.000Z"
},
"type": "versions",
"id": "urn:adsk.wipprod:fs.file:vf.d34fdsg3g?version=2",
"links": {
"self": {
"href": "/data/v1/projects/b.6f8813fe-31a7-4440-bc63-d8ca97c856b4/versions/urn%3Aadsk.wipprod%3Afs.file%3Avf.b909RzMKR4mhc3O7UBY_8g%3Fversion%3D1"
}
}
Normally, we would suggest you to use 3 legged token to modify a file in BIM360 Docs, because that will keep track the users who made the modification to that file(updated by). Yes you can also use 2 legged token for file management in BIM360 for now, but this behaviour may change in the future, and we will clearly mention in our blog if it happens.
There is no user information for any changes to the BIM360 files with 2 legged token, but there is one way, follow the Upload Files to BIM 360 Document Managemen Tutorial, in Step 7 & 8, add the x-user-id parameter in the header as the following picture, you will see the last modified user is filled.
Check this https://forge.autodesk.com/en/docs/bim360/v1/reference/http/users-GET/ if you want to know how to get the x-user-id information, should be uid(Autodesk ID).
We have a requirement from one of our clients to access the project files that are stored in the BIM360 Design (old Collaboration for Revit - C4R). I can not find any information in the developer pages of the Forge APIs that points to this location. I assume such an API is not part of Forge, but we were wondering if there is any other API that can provide those files.
The exact requirements are:
Constantly monitor for changes on the files located there.
When changes occur, retrieve and backup all those files to a local machine.
The question is, how, if possible, can we access the project files located at the BIM360 Design cloud?
UPDATE (10/04/2018)
We have found these commands - specifically PublishModel and GetPublishModelJob. This does something, we can at the very least prompt the publication on demand, without the need for Revit. It is not clear to me when the items:autodesk.bim360:C4RModel pseudo-file is created. On top of that, the API does not appear to be able to receive a prefered output folder, which makes it really cumbersome to work for the intended purpose of backing up the information inside BIM360 Design.
UPDATE (25/04/2018)
We have tried using both commands (PublishJob and GetPublishModelJob). We have impersonated a Project Admin (via the x-user-id) but Forge is returning a 401 error (which is not even documented). The following (with a redacted documentID) is what we have tried:
{
"jsonapi": {
"version": "1.0"
},
"data": {
"type": "commands",
"attributes": {
"extension": {
"type": "commands:autodesk.bim360:C4RModelGetPublishJob",
"version": "1.0.0"
}
},
"relationships": {
"resources": {
"data": [ { "type": "items", "id": "<document_id>" } ]
}
}
}
}
And this is Forge's response:
{
"jsonapi": {
"version": "1.0"
},
"errors": [
{
"id": "a4547153-1fd4-4710-b0d1-a7184d9e7e22",
"status": "401",
"code": "C4R",
"detail": "Failed to get publish model job"
}
]
}
Any thoughts?
After discussing with #tfrascaroli in Forge Help channel, we found the root cause of this error is caused by the incorrect value of x-user-id, so he didn't have the right permission to push the latest version of the C4R model to BIM360 docs.
{
"jsonapi": {
"version": "1.0"
},
"errors": [
{
"id": "a4547153-1fd4-4710-b0d1-a7184d9e7e22",
"status": "401",
"code": "C4R",
"detail": "Failed to get publish model job"
}
]
}
The x-user-id is not a GUID and not the id we saw in the response of GET users or GET users/:user_id, it should be the value of the uid. After replacing the x-user-id value by the uid, the error doesn't show up again.
[
{
"id": "a75e8769-621e-40b6-a524-0cffdd2f784e", //!<<< We didn't use it for `x-user-id`
"account_id": "9dbb160e-b904-458b-bc5c-ed184687592d",
"status": "active",
"role": "account_admin",
"company_id": "28e4e819-8ab2-432c-b3fb-3a94b53a91cd",
"company_name": "Autodesk",
"last_sign_in": "2016-04-05T07:27:20.858Z",
"email": "john.smith#mail.com",
"name": "John Smith",
"nickname": "Johnny",
"first_name": "John",
"last_name": "Smith",
"uid": "L9EBJKCGCXBB", //!<<<<< Here is the value for the x-user-id
"image_url": "http://static-dc.autodesk.net/etc/designs/v201412151200/autodesk/adsk-design/images/autodesk_header_logo_140x23.png",
"address_line_1": "The Fifth Avenue",
"address_line_2": "#301",
"city": "New York",
"postal_code": "10011",
"state_or_province": "New York",
"country": "United States",
"phone": "(634)329-2353",
"company": "Autodesk",
"job_title": "Software Developer",
"industry": "IT",
"about_me": "Nothing here",
"created_at": "2015-06-26T14:47:39.458Z",
"updated_at": "2016-04-07T07:15:29.261Z"
}
]
Do you have an access right to the workshared Revit file? Publish command is to publish workshared central model in the cloud to Docs. To use it, you need an access to Revit model in the central in the cloud. Forge Publish command does the same thing as publish command in Revit desktop. You need the same access right. To use cloud workshared feature, first you need to have Design license assigned to you, then you also need to be a member a Revit project. Being invited to Docs is not enough.
(As C4R/Design was merged to Docs recently, this C4R specific license part was intentionally kept the same as previous licensing. We also have Team for earlier versions. It makes it a bit complicated. I hope it will be easier as we move forward in future.)
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
}
]
}
Using the Google APIs Explorer as well as the official C# library for Google Drive API v3, the response is missing most of the documented fields. I specifically need access to who did the revisions, which should be accessible via $.lastModifyingUser.
I've tried this on my domain admin account as well as a service account, so it shouldn't be a permission issue, at least not that I can see. What am I doing wrong, if anything?
List:
{
"kind": "drive#revisionList",
"revisions": [
{
"kind": "drive#revision",
"id": "1",
"mimeType": "application/vnd.google-apps.spreadsheet",
"modifiedTime": "2016-11-16T18:29:29.527Z"
},
{
"kind": "drive#revision",
"id": "14",
"mimeType": "application/vnd.google-apps.spreadsheet",
"modifiedTime": "2016-11-16T18:35:49.184Z"
},
...
Single get:
{
"kind": "drive#revision",
"id": "134088",
"mimeType": "application/vnd.google-apps.spreadsheet",
"modifiedTime": "2017-05-24T11:48:00.788Z"
}
You need to add fields="*", or fields="permissions(id,lastModifyingUser)" to your request to instruct Drive to return the full resource. By default, only a minimal set of properties is returned.
I was not able to retrieve the "lastModifyingUser" from the revisions API but I was able to retrieve the "lastModifyingUser" from the Files.get fro example:
File foundFile = service.files().get(id)
.setSupportsTeamDrives(true)
.setFields("parents, webViewLink, properties, lastModifyingUser")
.execute();
System.out.println("Found file is " + foundFile);
System.out.println("Parents " + foundFile.getParents());
System.out.println("Owners " + foundFile.getOwners());
System.out.println("Props " + foundFile.getProperties());
System.out.println("Last user " + foundFile.getLastModifyingUser());
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.