How to POST/PUT markup json back to the dwf via API

How to POST/PUT markup json back to the dwf via API

dnguyennn
Enthusiast Enthusiast
250 Views
5 Replies
Message 1 of 6

How to POST/PUT markup json back to the dwf via API

dnguyennn
Enthusiast
Enthusiast

I am making a custom View panel using API, so far everything is working well. I was able to GET all the markup.json and displayed as the Vanilla one using:
https://aps.autodesk.com/en/docs/vaultdataapi/v2/reference/http/getfileversionmarkupbyid-GET/
How do I create or edit a markup back to Vault server? I tried and kept getting "405 method is not supported"
Is there any workaround? I am curious how Vault Desktop create/edit markups back to the server too, if I can do it thourgh C# SDK as a custom job.
Please help, thank you!

0 Likes
251 Views
5 Replies
Replies (5)
Message 2 of 6

Markus.Koechl
Autodesk
Autodesk

Vault Client (Desktop) saves markups as PropertyService.EntAttr. The SDK supports searching, creating, and writing attributes. However, the naming and content are undocumented due to their being subject to change at any time. Anyway, you can identify the current attributes using the namespace "Autodesk.FileMarkup.V1". The name best reflects your custom implementation, and the value is the markup JSON. Markups save with the file version, so the entityId is the File iteration.
Hope this helps.



Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
0 Likes
Message 3 of 6

dnguyennn
Enthusiast
Enthusiast

I am still struggling to GetEntityAttributes(selectedFile.Id, "Autodesk.FileMarkup.V1")

0 Likes
Message 4 of 6

dnguyennn
Enthusiast
Enthusiast

Hi Markus, do you have good example code somewhere? I have been struggling for couple days just on the Markups searching alone. 😭

0 Likes
Message 5 of 6

josebaqueror
Advocate
Advocate

The 405 is expected: the REST Data API endpoint for markups is read-only today, so GET works but there is no PUT/POST to write them back. Writing has to go through the classic Vault Web Service SDK (Autodesk.Connectivity.WebServices), not the REST Data API.

 

Markus is right that markups live as entity attributes (EntAttr) under the namespace "Autodesk.FileMarkup.V1", and the entity is the File iteration, not the master. That last part is what trips most people up: you query and write against the specific File version Id, using the File entity class.

 

The shape I use for reading/writing EntAttr through PropertyService:

 

var propSvc = mgr.PropertyService; // mgr = authenticated WebServiceManager

long[] entIds = new[] { fileIteration.Id }; // the FILE ITERATION id, NOT the master id

string[] namespaces = new[] { "Autodesk.FileMarkup.V1" };

EntAttrArray[] read = propSvc.GetEntityAttributes("FILE", entIds, namespaces); // READ; each EntAttr has .Name, .NS, .Val where .Val is your markup JSON

EntAttr attr = new EntAttr { NS = "Autodesk.FileMarkup.V1", Name = "the same Name Vault Desktop uses", Val = markupJsonString };

propSvc.UpdateEntityAttributes("FILE", entIds, new[] { attr }); // WRITE (create / update)

 

Two gotchas that cost me time on a project doing exactly this:

 

1. It has to be the file iteration Id. Pass the master Id and the write lands nowhere the desktop client will read.

 

2. The Name and JSON schema are undocumented and can change between releases. Read an existing markup made in Vault Desktop first, then mirror its exact Name and structure before writing your own. Do not invent the Name.

 

If GetEntityAttributes comes back empty for a file you know has markups, check you are hitting the iteration (not the "latest" shortcut) and that the class id string matches.

Jose Luis Baquero Rivera
Mechanical Engineer
Open to projects, feel free to contact me
josebaqueror.com
https://www.linkedin.com/in/joseluisbaquerorivera/
Message 6 of 6

Markus.Koechl
Autodesk
Autodesk

Hi, @dnguyennn: To complete the feedback for the .NET API as well, I cross-checked the topic with development and got confirmation that we differentiate "client" and "server" attribute types internally. The currently available .NET API handles "client" attributes only. As a result, you can only read/write attributes that you have written with your custom namespace. It may change in the future; @josebaqueror obviously succeeded in reading using the (newer) Data API.
I kindly ask for caution with your concepts: undocumented schemas are subject to change at any time, and we put open APIs at risk if we cross the borders of documented usage.

@dnguyennn: Please accept my apologies that I did not note the distinction between 'client' and 'server' attributes in my earlier reply.



Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe