Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X
Hi,
I am working on a Thingworx extension that creates an excel file by passing an infotable parameter. The infotable contains strings and TwoDThumbnailURL.URL obtained from `Things["intralox-windchill-odata-connector-illustrated-parts"].GetPartRepresentations`.
So far the TWX extension successfully creates the excel file with string parameters, the challenge is rendering TwoDThumbnailURL images.
I have proven that the downloaded jgp file from TwoDThumbnailURL.URL can be embedded in an excel spreadsheet by doing the following steps:
Is there a programmatic way to do steps 2-4 described above that would download the TwoDThumbnailURL to obtain the jpg file and add it to a File Repository?
TIA!
let image = Resources["ContentLoaderFunctions"].LoadImage({url:"https://www.ptc.com/dist/ptc/images/ptc-favicon-144x144-gray.png"});
Things["SystemRepository"].SaveImage({ path: "/Myimage.png", content: image});
Thanks @Rocko,
I tried this out but when the file is downloaded from the repo it was saved to instead of an image the following is rendered:
I am using the TwoDThumbnailURL.URL value for the url parameter in LoadImage, this is an example:
https://<server>/Windchill/oauth/servlet/WindchillAuthGW/wt.fv.master.RedirectDownload/redirectDownload/DPP-1751421.jpg?u8&redirect=true&ContentHolder=wt.viewmarkup.DerivedImage%3A1302633096&HttpOperationItem=wt.content.ApplicationData%3A1302633103&forceDownload=true"
If I remove "oauth" and past in browser the image is downloaded and renders successfully.
Perhaps I need to further prep/modify the TwoDThumbnailURL.URL before running LoadImage?
It looks like the URL you have does a redirect, since you are calling a Servlet on Windchill side. This is then interpreted by the browser, so you don't get the image directly.
You can check the downloaded broken image and open it in a text editor to see what the LoadImage received.
You can also try to download the image from your browser and then use Developer Tools (F12) or Copy Download link from the browser's "Downloads" button to see what is the correct URL.
You might have to do a Resources["ContentLoaderFunctions"].GetText first, read the result and get the final URL from there.
The URL is definitely trying to do a redirect, the broken image is returning a Shibboleth Authentication Request message when "oauth" is removed and a "General purpose Windchill error page" when it isn't removed. Same when using GetText function.
I also tried with Postman with the same results.
Could this be an authentication issue? Any tips to avoid the redirect?
Yes, this is about the authentication. When you use the ODataConnector to access Windchill, you configured an authentication with it. But the ContentLoaderFunction does not know about this, it creates its own connection to WT to get the image, but wasn't authenticated. You will have to put the authentication information into the header parameter of the GetText/GetImage call, so Windchill can authenticate the TWX server.
Can you provide an example header for an SSO configured environment?
Also, can you share the link with reference documentation explaining best practice for handling this scenario?
Thank you,
Maria
I haven't, sorry.
But I would assume you're not using SSO with the OData Connector but a fixed account which is configured in the Configuration Tab of the Odata Connector. This is the account data you must put into the header of the ContentLoader call. Whoever configured "intralox-windchill-odata-connector-illustrated-parts" should be able to give you the credentials.
My 2 cents:
/ Constantine
Hi @mariaSutton ,
It appears that a response to this post answers your question. For the benefit of other Community Members who may have the same question, it would be great if you could designate an appropriate reply as the Accepted Solution.
In the event that this response did not answer your question, please post your current status so that we can continue to support.
Thanks for using the PTC Community!
Regards,