"sequence_id" in Box.com Create Folder API call - box-api

In Box.com API document it is written that, if you will create a folder then you will get some response.
So I have gone through the response, and wondering what is "sequence_id" means in this block of of code.
"parent": {
"type": "folder",
"id": "0",
"sequence_id": null,
"etag": null,
"name": "All Files"
},
Regards

The folder with id=0 is the users "root" folder. As such it isn't a real folder with an etag or a sequence_id. Every other folder at every other level will have a non-zero id, and will have a sequence_id and a non-null etag.

Related

Set Updated by when uploading files to BIM360 Docs with 2-legged authentification

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).

Access files located in the WIP folder of BIM360 Design (old C4R)

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.)

Get UserId of shared calendar's owner using MS Graph API

I want to get the User's profile that shared a Calendar with me but this call needs the id or userPrincipalName:
GET /users/{id | userPrincipalName}
The shared calendar only returns:
{
"id": "**********************************************=",
"name": "Lala Lalala",
"color": "auto",
"changeKey": "Epg+nQ9k3kuTN16cfoLtwAAAsZgDvA==",
"canShare": false,
"canViewPrivateItems": false,
"canEdit": true,
"owner": {
"name": "Lala Lalala",
"address": "Lalala#outlook.com"
}
}
So how can I get the id or userPrincipalName of the shared calendar's owner?
For Work/School Accounts (Azure AD tenants), the userPrincipalName is the owner's address (i.e. alias#aad.domain.com):
"owner": {
"name": "Lala Lalala",
"address": "Lalala#outlook.com"
}
Assuming they're in the same tenant as your, you can retrieve their profile using GET https://graph.microsoft.com/v1.0/users/{owner.address}.
Important: This does not, however, apply to Personal Accounts (MSA/Outlook.com). I only mention this because your example used Lalala#outlook.com as the address.
Since Outlook.com is effectively a "single user" tenant, the only user you can retrieve is yourself (/me). Just as you cannot access a user's data from another company's AAD, you cannot retrieve another Outlook.com user's profile. If you consider the pricacey implications of my access your personal contact information, it makes sense why this rule is in place.
No directly way to implement what you want. But you can get the id or userPrincipalName by two steps:
Get calendars whose owner is not you, the response like you have posted(official docs):
https://graph.microsoft.com/v1.0/me/calendars
Use the address in the owner to call the following API:
https://graph.microsoft.com/v1.0/users/{address}
The response with id and userPrincipalName:
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#users/$entity",
"id": "5eec0ff7-b007-48c4-87ae-7cddb085f234",
"businessPhones": [],
"displayName": "...",
"givenName": "...",
"jobTitle": null,
"mail": "test#test.com",
"mobilePhone": "8612345678",
"officeLocation": "No WorkSpace",
"preferredLanguage": null,
"surname": "s",
"userPrincipalName": "test#test.com"
}

How to get the full file path of a Box File given file ID using the API

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();
}

https://www.googleapis.com/drive/v2/files/<fileid>/comments?alt=json returned "Not Found" on a file that can't be opened

More details as below:
https://www.googleapis.com/drive/v2/files/1iNMGIAFXuhS_CO_hnEO0_EJ9PAgT-hXYqWYv0MPGUTI/comments?alt=json returned "Not Found
The file is present in drive and shows in drive.changes.list, but can't be opened in Google Drive either.
There are two problems here
a) the file is somehow corrupt ( it was a document imported into drive, so that failed, but that isn't something I care about for the purposes of this question )
b) The file shows up as existing in some API calls, but calls to read comments with the Drive SDK comments API fail.
Here are results from an API call showing how the file does indeed exist:
"file": {
"kind": "drive#file",
"id": "1iNMGIAFXuhS_CO_hnEO0_EJ9PAgT-hXYqWYv0MPGUTI",
"etag": "\"o35FABD0TC3H-Up3OL3UA9kEB2w/MTM3MTc2NzU5NzEyNA\"",
....
....
"iconLink": "https://ssl.gstatic.com/docs/doclist/images/icon_11_document_list.png",
"title": "<removed>",
"mimeType": "application/vnd.google-apps.document",
"labels": {
"starred": false,
"hidden": false,
"trashed": true,
"restricted": false,
"viewed": true
},