Hi,
I am looking for some advice on retrieving an IMAGE using the REST API. As a recap, I am able to log into PLM360, get the workspaces and see all of the items in the workspace. I am also able to retrieve the workspace details to get the field information for that workspace. From there, I can pick on an individual item, and display all of the data, except when it comes to IMAGE field types.
When I see the IMAGE field type, I look at the field value from the item and get the URL that I think would be used to retrieve the file.
i.e. "https://xxxxx.autodeskplm360.net/api/v2/workspaces/47/items/2694/field-values/IMAGE"
Using the restsharp library, I take the URL, add the same cookies that I have always been adding to each of my calls. For regular data, I have been adding
accept: application/json
to the request headers. For the image call, I have been adding
accept: image/jpeg
I execute the request and just receive the standard NotFound error and get back the normal error page as if I had been browsing manually. This happens on any item that has an image attached to it.
I can't help but feel like I am missing something blindingly obviously.
Thanks
Mike
Solved! Go to Solution.
Solved by mike.ponti. Go to Solution.
I don't think you need to specify the accept types when reading an image field.
If you want some sample code grab the handout and additional materials for the AU class: Programming Autodesk PLM 360 Using REST
The materials go over a bunch of workflows related to binary data, including downloading an image.
Thanks Doug, I will rework my code as you have in the sample and see how it goes. On the surface, the only real difference I see is that I was using the URL that was provided in the field value instead of constructing the URL manually as in your sample.
Thanks
Mike
Hi Doug,
Just an update on this. Looks like my url's were correct. Where it was coming apart was the fact that I was using the RestSharp library to handle my rest calls and I think it was defaulting some deserialization handlers into the request. I think this then put in some additional headers which caused the "Not Found" error (not totally sure about that).
When I removed the handlers before making the call, it would then return the binary content.
Thanks for your help,
Mike