I am just testing to use the Web API to download image from dataverse.
Web API below would download a corrupt file instead of the correct image file uploaded into the dataverse table entry. It is already configured to have GLOBAL table permission with read access for everyone including anonymous users, with site settings applied.
https://[PORTALURL].powerappsportals.com/_api/accounts(7f240c9e-1d74-ec11-8943-00224812ee84)/entityimage/$value
However dynamics web api below would correctly download the image file:
https://[ORG].crm6.dynamics.com/api/data/v9.1/accounts(7f240c9e-1d74-ec11-8943-00224812ee84)/entityimage/$value
I am not sure where I should report this issue but it is definitely becoming an issue when trying to render image/download files directly. I cannot use the dynamics web api url since it is not available for anonymous users to consume (requirement)
Solved! Go to Solution.
I got this link that is very related to the issue you are facing:
It's a planned feature and is written: "A user can download the image directly from portal forms or with the portals Web API." so probably when this feature will be implemented you will not face the issue, meanwhile the only alternative is the javascript.
hope it helps
are you using a direct link to download it or a javascript code? if is a javascript code can you share it?
Usually there are problems to upload an image to that kind of fields (due to javascript enconding) but being a download a GET request you should not have
I am using direct link to download it, for images if you do:
<img src="https://[ORG].crm6.dynamics.com/api/data/v9.1/accounts(7f240c9e-1d74-ec11-8943-00224812ee84)/entityimage/$value" /> --> this will render correct image
<img src="https://[PORTALURL].powerappsportals.com/_api/accounts(7f240c9e-1d74-ec11-8943-00224812ee84)/entityimage/$value" /> --> broken image will be rendered
If you go to https://[PORTALURL].powerappsportals.com/_api/accounts(7f240c9e-1d74-ec11-8943-00224812ee84)/entityimage without $value, correct base64 string will be returned but it would not be ideal to render the image directly on site as I will have to write a JS function to render the image.
thanks for the reply. The syntax with and without $value works with all the columns, if for example instead of entityimage you put name you will get the name of the account.
Probably the fact $value is not working correctly has to do with the MS implementation of the _api endpoint (I imagine that with the standard endpoint it returns the blob, with _api endpoint it returns the base64 value and see the broken one), more than opening a ticket to solve this specific issue you can't do I am afraid.
Writing a js function to render the image would not be difficult (as many browsers can render the base64 encoding if the proper start tag is written inside the src), but it will require you to get the base64 first inside a jquery call first.
Thanks. Yes correct. When you go directly to /$value, it actually downloads corrupt $value (utf-8) file.
If you perform an http request into https://[PORTALURL].powerappsportals.com/_api/accounts(7f240c9e-1d74-ec11-8943-00224812ee84)/entityimage it would return something like below, which I will need to write a JS function to perform the request, get the value and render into the src tag.
{ "@odata.context": "https://xxx.powerappsportals.com/_api/$metadata#accounts(7f240c9e-1d74-ec11-8943-00224812ee84)/entityimage", "value": "iVBORw0KGgoAAAA...."
}
This is definitely a bug that I will need to raise to microsoft however I am not sure where to raise as normal tickets would probably just be ignored (reason as always, API is not within their area of support).
I got this link that is very related to the issue you are facing:
It's a planned feature and is written: "A user can download the image directly from portal forms or with the portals Web API." so probably when this feature will be implemented you will not face the issue, meanwhile the only alternative is the javascript.
hope it helps
A colleague of mine got this working with JavaScript using two different endpoints:
Get file
Thanks! Unfortunately the url is trimmed, are you able to post just the url strings?
Update:
https://[PORTALURL].powerappsportals.com/_api/accounts([INTERNAL_ID])/entityimage?size=full --> it displays the JSON result with value as base64. If we have lots of images there will be a performance overhead to get the value and then JS will set the img src.
I guess as GuidoPreite mentioned, I'll either raise this as an issue with support or just wait until endpoint below is fixed and spits out the correct file.
https://[PORTALURL].powerappsportals.com/_api/accounts([INTERNAL_ID])/entityimage/$value?size=full
Sorry! The mobile experience of this forum is killing me...
[PORTALURL].powerappsportals.com/_api/[ENTITY INTERNAL NAME IN PLURAL](ef4c3329-6262-ec11-8f8f-000d3a2d17b3)/[NEW FILE TYPE COLUMN INTERNAL NAME]?size=full
User | Count |
---|---|
3 | |
1 | |
1 | |
1 | |
1 |