How do I get the document path using the Autodesk A360 API? - autodesk-forge

When looking at the API documentation, it states it should be able to set a query parameter: includePathInProject. Using that, the relative path should be included in the response.
includePathInProject
Specify whether to return pathInProject attribute in response for BIM 360 Docs projects. pathInProject is the relative path of the item starting from project’s root folder.
true: response will include pathInProject attribute for BIM 360 Docs projects.
false (default): response will not include pathInProject attribute for BIM 360 Docs projects.
However, when I try this in Postman, I get this message:
{
"jsonapi": {
"version": "1.0"
},
"errors": [
{
"id": "34a40e9d-2db2-4a32-ac9a-fc0642207266",
"status": "400",
"code": "FUNCTION_NOT_SUPPORTED",
"detail": "A360 currently does not support query parameter includePathInProject."
}
]
}
This is the request URL I'm using:
https://developer.api.autodesk.com/data/v1/projects/:project_id/items/:item_id?includePathInProject=true
project_id: a.Yna[...]zgx
item_id: urn:adsk.wipprod:dm.lineage:0P0E[...]l5A
Is there any other way or workaround to get the path of a document?

It seems that you're trying to use it for A360 projects, I see an a. prefix on your project id. This parameter applies to BIM 360 only.

Related

Autodesk Construction Cloud API unavailable endpoints

Our team is working with Autodesk Construction Cloud and it's Docs module quite heavily. Because of that we're trying to develop some internal tools which would automate some work that they do, mostly around copying files.
In ACC Docs you can easily copy files from one folder to another. From our investigation it looks like the ACC internally uses an endpoint like this to copy the files:
https://developer.api.autodesk.com/dm/v3/projects/{{projectId}}/documents:copy?targetFolder={{targetFolder}}
By using the authentication token from ACC requests (obtained from the browser), we can easily use this call from Postman or even an AWS Lambda function. But when we're using the auth tokens obtained from 3-legged auth process as described in the documentation, the same API call fails.
Is it even possible right now to obtain an auth token which works with that endpoint for copying ACC Docs files? Or is this not available right now as this API is still not really "public"?
Happy New Year!
Those APIs are internal APIs. Please do not try to use them. even if it may work, you would use it on your own risk..
Regarding with copy files files from one folder to the other, you can use the public API. After you get the version urn of the original file, call the endpoint below with the parameter
POST https://developer.api.autodesk.com/data/v1/projects/{PROJECT_ID}/items?copyFrom=urn%3Aadsk.wipprod%3Afs.file%3Avf.rH_L4XJsTmeiYA4ixCVNAA%3Fversion%3D1
with the payload, in which specify the target folder.
{
"jsonapi": {
"version": "1.0"
},
"data": {
"type": "items",
"relationships": {
"tip":{
"data":{
"type":"versions",
"id":"1"
}
},
"parent": {
"data": {
"type": "folders",
"id": "urn:adsk.wipprod:fs.folder:co.0xaYa2rVTJuFiz7rxLCOQQ"
//!<<< The folder we want to put this file
}
}
}
},
"included":[
{
"type":"versions",
"id":"1",
"attributes":{
"name":"rac_basic_sample_project.rvt" //!<<< Version name
}
}
]
}

Error while trying to Display an SVF from a BIM 360 URN

I'm trying to display a revit model stored in BIM 360 using the code example from this repository: https://github.com/Autodesk-Forge/forge-tutorial-postman/blob/master/docs/display_svf.html
In this html file I only need to give my access token and the URN (encoded). This works if my model is uploaded from a bucket I had created, but I'm getting an Failed fetching Forge manifest error when I try to do it from an URN that I got from a BIM 360 document.
These are the steps I'm taking:
Getting the document URN
I used this endpoint https://developer.api.autodesk.com/data/v1/projects/b.ef7b0d22-8480-40d6-9749-12e5d7192ac9/folders/urn:adsk.wipprod:fs.folder:co.nAdJ4fwLRRuGem-qpDIlTA/contents
And from the results I get my urn:
Encode the URN
After that I got to https://www.base64encode.org/ and encode the value
urn:adsk.objects:os.object:wip.dm.prod/ac9e8b48-4a51-4f6a-a7e4-a947c9d6a1e6.rvt
And the result is this:
dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6d2lwLmRtLnByb2QvYWM5ZThiNDgtNGE1MS00ZjZhLWE3ZTQtYTk0N2M5ZDZhMWU2LnJ2dA
Set my access token and encoded URN in display_sfv.html
After that I place my acces token and the encoded URN, like this:
Finally I got this errors from the console:
Again this example works if I use and urn from a bucket I had created, but when I use the urn I get from a BIM 360 folder I get that error message. Where could be my mistake?
To load models form BIM360, you have to use the urn under derivatives attribute like below:
"derivatives": {
"data": {
"type": "derivatives",
"id": "dXJuOmFkc2sud2lwcWE6ZnMuZmlsZTp2Zi50X3hodWwwYVFkbWhhN2FBaVBuXzlnP3ZlcnNpb249MQ"
},
"meta": {
"link": {
"href": "/modelderivative/v2/designdata/dXJuOmFkc2sud2lwcWE6ZnMuZmlsZTp2Zi50X3hodWwwYVFkbWhhN2FBaVBuXzlnP3ZlcnNpb249MQ/manifest?scopes=b360project.6f8813fe-31a7-4440-bc63-d8ca97c856b4,global,O2tenant.tenantId"
}
}
},
Ref: https://forge.autodesk.com/en/docs/data/v2/reference/http/projects-project_id-versions-version_id-GET/

resourceData returns null for microsoft graph API webhook for Sharepoint Online

I am trying to set webhook notification for SharePoint Online drive using MS Graph API. The subscription is setup. Whenever I make any change in the drive by adding/deleting a file I get a notification but the resourceData is null.
Is this standard behaviour?
{"value":[
{"subscriptionId":"XXX",
"clientState":"secretClientValue",
"tenantId":"XXX",
"resource":"drives/<id>/root",
"resourceData":null,
"changeType":"updated",
"subscriptionExpirationDateTime":"2019-01-22T18:23:45.9356913+00:00"
}
]
}
Thank you for any suggestions.
Not all resources return resourceData within the notification itself, OneDrive is one of these.
OneDrive will return the following properties:
{
"subscriptionId": "string",
"expirationDateTime": "datetime",
"resource": "relative url",
"clientState": "string optional",
"changeType": "updated"
}
You can find the spesific documentation for this entity here.

Unable to create webhook for Autodesk BIM 360 docs project

I am trying to create a webhook for Autodesk BIM 360 project and ended with this error - "Access denied for the scope that you are trying to create hook on". I am using Postman to test the webhook creation - Here is the response which I am getting -
{
"hooks": [],
"errors": [
{
"id": "071ec72d-20b5-40c1-9451-ee9cdf573984",
"status": 403,
"code": "FORBIDDEN_ERROR",
"detail": [
"Access denied for the scope <projectId> that you are trying to create hook on"
],
"source": {
"sysType": "adsk.wipprod",
"eventType": "fs.file.added",
"callbackUrl": "http://6bd04cad.ngrok.io/webhooks/bim360",
"scope": {
"folder": "<projectId>"
},
"hookAttribute": null
}
}
]
}
What are the scopes you are passing on, did you follow this tutorial? Has the trial been activated for your keys?
https://developer.autodesk.com/en/docs/webhooks/v1/tutorials/create-a-hook-data-management/
I was facing this issue due to having old forge application which didn't configure the Webhook. Now I have enabled it and it's fixed.
Now I am facing a different issue which is related to access denied. Here is the detail -
creating a Webhook for BIM 360 docs using Autodesk forge custom integration. I am following this Webhook API documentation https://developer.autodesk.com/en/docs/webhooks/v1/reference/http/systems-system-events-event-hooks-POST/ and am constantly getting this response.
{
“id”: “888134c7-fd22-4676-b907-d8441477dde4",
“status”: 403,
“code”: “FORBIDDEN_ERROR”,
“detail”: [
“Access denied for the scope b.2210c698-4e4b-47d0-b579-f92a969ef365 that you are trying to create hook on”
]
}
From your question, it seems that you used the projectId or hubId, make sure to use folderId as the scope, it should be similar to urn:adsk.wipprod:fs.folder:abcd1234

File not found error Google Drive API

I am using the Drive REST API to download a file. I am making a GET request using the file id and I get a file not found exception.
{
"error": {
"errors": [
{
"domain": "global",
"reason": "notFound",
"message": "File not found: xxxxx",
"locationType": "other",
"location": "file"
}
],
"code": 404,
"message": "File not found: xxxxx"
}
}
I have also generated the apikey and I am using it in my GET request.The file does exist so I am unsure what I am missing here.
Make sure scopes are corrects
var url = oauth2Client.generateAuthUrl({
access_type: 'offline',
scope: ['https://www.googleapis.com/auth/drive.file',
'https://www.googleapis.com/auth/drive',
'https://www.googleapis.com/auth/drive.file',
'https://www.googleapis.com/auth/drive.metadata'
]
});
Drive API declares the following scopes. Select which ones you want to grant to APIs Explorer.
https://www.googleapis.com/auth/drive
View and manage the files in your Google Drive
https://www.googleapis.com/auth/drive.appdata
View and manage its own configuration data in your Google Drive
https://www.googleapis.com/auth/drive.file
View and manage Google Drive files and folders that you have opened or created with this app
https://www.googleapis.com/auth/drive.metadata
View and manage metadata of files in your Google Drive
https://www.googleapis.com/auth/drive.metadata.readonly
View metadata for files in your Google Drive
https://www.googleapis.com/auth/drive.photos.readonly
View the photos, videos and albums in your Google Photos
https://www.googleapis.com/auth/drive.readonly
View the files in your Google Drive
https://www.googleapis.com/auth/drive.scripts
Modify your Google Apps Script scripts' behaviour
Sorce: https://developers.google.com/apis-explorer/#p/drive/v3/drive.files.get
This is resolved. I wasn't providing the correct access_token when making the GET request for file metadata. I regenerated the authorization code, access_token and my code is working now.
In my case, I simply had not given access to the folder to my service account. Simply sharing it via the web interface solved the problem.
What email address to use:
Check the email address of your service account here:
https://console.cloud.google.com/iam-admin/serviceaccounts?project=NAME_OF_PROJECT&supportedpurview=project
The email address will look like this:
name-of-service-account#name-of-project.iam.gserviceaccount.com
I would check to see if the file you are trying to retrieve the metadata for is part of a team drive; if it is then you have to set supportsTeamDrives=True in the request.
If you are getting a response like this:
<HttpError 404 when requesting https://www.googleapis.com/drive/v3/files/REDACTED_FILE_ID/copy?alt=json returned "File not found: REDACTED_FILE_ID.". Details: "[{'domain': 'global', 'reason': 'notFound', 'message': 'File not found: REDACTED_FILE_ID.', 'locationType': 'parameter', 'location': 'fileId'}]">
And the fileId points to a file on a Shared Drive, you'll need to include supportsSharedDrives=true in your request parameters.
Google provides more detail on this in their Implement shared drive support article.
Here's a small example with Python for creating a copy:
googledrive = build('drive', 'v3', credentials=creds)
copy_response = googledrive.files().copy(
fileId=TEMPLATE_SPREADSHEET_ID,
body={
"parents": [
report_folder_id,
],
'title': report_title
},
supportsAllDrives=True
).execute()
In order to run that, you'll want to mix it into the example code from the Python Quickstart for Google Drive API.
I got to this question because I was getting a "File not found" error when using the update method.
I was using this line in Python to execute the method:
files_res.update(fileId=f_id, body={"name": f_name}).execute()
I could list the shared file and its parent fine, but update failed, no matter what the scope with this error:
...
"errors": [
{
"domain": "global",
"reason": "notFound",
"message": "File not found: 1YqV...",
"locationType": "parameter",
"location": "fileId"
}
],
"code": 404,
...
I added the supportsAllDrives=True param to the method and it worked:
files_res.update(fileId=f_id, body={"name": f_name}, supportsAllDrives=True).execute()
In my case, I was using the file client_secret.json that I had created with the gmail address I use all the time, but I was creating the credentials with another e-mail.