When you publish a revision of a document using the API, is it necessary to change the filename? When I leave the name the same, a new revision is not created despite including the document id in the request so that the file can be replaced. The JSON file returns a revision count that is the same as the previous version and a revision position of 0. I am having to change the filename to be saved in BIM 360 as well as including the document id in the POST request. This is different to uploading from within BIM 360 where the filename needs to be the same for a revision to be created. Is this working correctly for me?
Solved! Go to Solution.
When you publish a revision of a document using the API, is it necessary to change the filename? When I leave the name the same, a new revision is not created despite including the document id in the request so that the file can be replaced. The JSON file returns a revision count that is the same as the previous version and a revision position of 0. I am having to change the filename to be saved in BIM 360 as well as including the document id in the POST request. This is different to uploading from within BIM 360 where the filename needs to be the same for a revision to be created. Is this working correctly for me?
Solved! Go to Solution.
Solved by xiaodong_liang. Go to Solution.
Hi @JarredJackson,
Could you clarify if this is a question on BIM 360 Docs API (Forge), or BIM 360 Glue API (legacy API) ?
regarding with BIM 360 Docs API (Forge), different version corresponds to different physical file. So you will need to create a cloud storage and upload the new file, then call update a new version to associate the virtual item (v1, v2 ,v3...) with the physical file.
my colleague has produced a nice blog on the detail. Could you take a look if it helps?
Hi @JarredJackson,
Could you clarify if this is a question on BIM 360 Docs API (Forge), or BIM 360 Glue API (legacy API) ?
regarding with BIM 360 Docs API (Forge), different version corresponds to different physical file. So you will need to create a cloud storage and upload the new file, then call update a new version to associate the virtual item (v1, v2 ,v3...) with the physical file.
my colleague has produced a nice blog on the detail. Could you take a look if it helps?
Hi @xiaodong_liang,
My question was in relation to the BIM 360 Field - API Doc (Field Classic). Using the library in BIM 360 Field Classic, a revision is added to a document when it is uploaded with the same name as an existing document. Using the POST /api/library/publish function of the API, I am having to change the filename before a revision is created, despite the document_id being included in the request.
Hi @xiaodong_liang,
My question was in relation to the BIM 360 Field - API Doc (Field Classic). Using the library in BIM 360 Field Classic, a revision is added to a document when it is uploaded with the same name as an existing document. Using the POST /api/library/publish function of the API, I am having to change the filename before a revision is created, despite the document_id being included in the request.
Hi @JarredJackson,
I took time to test the workflow with my project. The API is working well. The following is the code snippet of publishing new version. I do not even need to specify the document_id. I just ensured the file name is same.
The only behavior I observed: if the new version file is same to the last version, the 'new version' will not be generated in Field, though Publish succeeded. This is same to UI and makes sense to me. maybe what you encountered is because you published a same file (same file name and same MD5/SHA1) ?
Could you check if my code snippet that could help you diagnose the problem? if you still have the issue, please isolate and send us a small test sample.
void field_publishDoc() { var client = new RestClient("https://bim360field.autodesk.com"); var request = new RestRequest(Method.POST); request.Resource = "api/library/publish?replace=0"; request.AddParameter("ticket", thisticket); request.AddParameter("project_id", pjoId); request.AddParameter("directory", "Equipment"); //request.AddParameter("document_id", "zzzz-zzz-zzz-zzzz-zzzzzzz"); request.AddParameter("filename", System.IO.Path.GetFileName("xiaodongtest.pdf")); request.AddFile("Filedata", @"c:\temp\xiaodongtest.pdf"); var response = client.Execute(request); if(response.StatusCode == HttpStatusCode.Created) { byte[] file_bytes = response.RawBytes; } else { System.Diagnostics.Debug.Write("publish failed: " + response.StatusDescription); } }
Hi @JarredJackson,
I took time to test the workflow with my project. The API is working well. The following is the code snippet of publishing new version. I do not even need to specify the document_id. I just ensured the file name is same.
The only behavior I observed: if the new version file is same to the last version, the 'new version' will not be generated in Field, though Publish succeeded. This is same to UI and makes sense to me. maybe what you encountered is because you published a same file (same file name and same MD5/SHA1) ?
Could you check if my code snippet that could help you diagnose the problem? if you still have the issue, please isolate and send us a small test sample.
void field_publishDoc() { var client = new RestClient("https://bim360field.autodesk.com"); var request = new RestRequest(Method.POST); request.Resource = "api/library/publish?replace=0"; request.AddParameter("ticket", thisticket); request.AddParameter("project_id", pjoId); request.AddParameter("directory", "Equipment"); //request.AddParameter("document_id", "zzzz-zzz-zzz-zzzz-zzzzzzz"); request.AddParameter("filename", System.IO.Path.GetFileName("xiaodongtest.pdf")); request.AddFile("Filedata", @"c:\temp\xiaodongtest.pdf"); var response = client.Execute(request); if(response.StatusCode == HttpStatusCode.Created) { byte[] file_bytes = response.RawBytes; } else { System.Diagnostics.Debug.Write("publish failed: " + response.StatusDescription); } }
Can't find what you're looking for? Ask the community or share your knowledge.