Upchain RESTful API: Acquiring the FileVersionId

Upchain RESTful API: Acquiring the FileVersionId

moses_correia
Participant Participant
1,728 Views
9 Replies
Message 1 of 10

Upchain RESTful API: Acquiring the FileVersionId

moses_correia
Participant
Participant

I am attempting to use the Upchain RESTful API to get information about files attached to items within a BOM.  The issue is that I cannot find the API call (or chain of calls) to acquire the FileVersionId.  I have the PartVersionId of the item that has the attached file AND I can acquire a DocumentVersionId of the file ... but that does not appear to be the same thing as the FileVersionId.

 

Anyone familiar with the Upchain RESTful API that can provide any insight, it is appreciated.  I'm currently using Swagger's documentation:  https://live.upchain.net/swagger-ui/index.html?configUrl=/v3/api-docs/swagger-config#

0 Likes
Accepted solutions (1)
1,729 Views
9 Replies
Replies (9)
Message 2 of 10

sven.dickmans
Autodesk
Autodesk

I created a utility to download files from an item in Upchain. This utlity triggers two subsequent calls:

 

1) Using the partVersionId, get the primary file's fileVersionId:

https://live.upchain.net/api/bom/v1/part_version/' + partVersionId + '/latest_primary_file_version_object

 

b) Using this fileVersionId, download the given file

 

'https://live.upchain.net/api/bom/v1/file_version/' + file.PbFileVersionId + '/download'

 

 

You can find the whole script attached. Does this help?

0 Likes
Message 3 of 10

moses_correia
Participant
Participant

I did try "latest_primary_file_version" and "latest_primary_file_version_object" previously, but file_version returned a result of 0 and file_version_object returned nothing.  This is after I added 3 files to the item:  1 in the General Documents, 1 in Linked Documents, and 1 in Specification Documents -> Firmware.

 

Do you know where exactly I am supposed to put the file or what state the file has to be in for it to be considered a *primary* file?

0 Likes
Message 4 of 10

sven.dickmans
Autodesk
Autodesk

Sorry, I was not aware that you want to access General and Linked documents. With latest_primary_file_version, you can retrieve the cBOM file specifically. So if you grab the partVersionId from the URL in your browser ... 

 

CBOM.png

 

... 'https://live.upchain.net/api/bom/v1/part_version/' + partVersionId + '/latest_primary_file_version_object' will provide details about this given CAD file.

 

response.png

 

I have to check how the other documents can be accessed as well.

0 Likes
Message 5 of 10

moses_correia
Participant
Participant
Thanks. My requirements identify multiple locations that files may be located so best to make sure I can search them all.
0 Likes
Message 6 of 10

sven.dickmans
Autodesk
Autodesk

https://live.upchain.net/api/bom/v2/item-versions/document-versions
might be of help. This endpoint returns all files except for the primary file. Here is my data ...

 

ui.png

 

 

... and here is the response of

 

https://live.upchain.net/api/bom/v2/item-versions/document-versions?id=713981

 

response.png

 

However, I guess this is how far you got by yourself already as you have access to documentVersionId already. You want to get the documents' fileVersionId instead to be able to download these files, correct?

0 Likes
Message 7 of 10

sven.dickmans
Autodesk
Autodesk
Accepted solution

Just noticed that you can download the given files with the documentVersionId of the previous requests using this endpoint:

https://live.upchain.net/api/dms/v1/document/' + documentVersionId + '/file
Message 8 of 10

moses_correia
Participant
Participant
There it is! DMS ... what does that stand for ... document management system?? I figured the API calls for using the documentVersionId were hiding somewhere. Thanks very much.
0 Likes
Message 9 of 10

sven.dickmans
Autodesk
Autodesk

Need more details about the document? Use 

 

'https://live.upchain.net/api/dms/v1/document/' + documentVersionId + '/tree'

 

to access the document itself:

 

response.png

Message 10 of 10

imckenzieY7CGY
Advocate
Advocate

@sven.dickmans Would you have any ideas as to why I seem to sporadically get a 'File not found' response when I use your initially suggested method of downloading the primary document? On some items. it works and I end up with a downloaded file, but on others I get a response like:

 

{"message":"File not found","instance":"e3f ........ "detailKeyParameters":["82294517"],"fields":["fileVersionId.........}

 

I've double checked and 82294517 what is returned for PbFileVersionId when I make a call to:

/api/bom/v1/part_version/38909583/latest_primary_file_version_object

 

And I know that the item where I got 38909583 has a primary file and can be downloaded normally. It's weird because on some other items the download completes as expected and I can't tell what's different about them or the request I'm making. 

0 Likes