web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / Power Portal Web API g...
Power Pages
Unanswered

Power Portal Web API get file/image /$value issue

(1) ShareShare
ReportReport
Posted on by 12

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)

 

Categories:
I have the same question (0)
  • Guido Preite Profile Picture
    1,488 Super User 2024 Season 1 on at

    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

  • jaditya Profile Picture
    12 on at

    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.

  • Guido Preite Profile Picture
    1,488 Super User 2024 Season 1 on at

    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.

  • jaditya Profile Picture
    12 on at

    Thanks. Yes correct. When you go directly to /$value, it actually downloads corrupt $value (utf-8) file.

    jonathanhotono_0-1645864700456.png

     

    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).

  • Verified answer
    Guido Preite Profile Picture
    1,488 Super User 2024 Season 1 on at

    @jonathanhotono 

    I got this link that is very related to the issue you are facing:

    https://docs.microsoft.com/en-us/power-platform-release-plan/2022wave1/power-apps-portals/portals-support-image-columns-dataverse

    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

  • m3ngi3 Profile Picture
    725 on at
  • jaditya Profile Picture
    12 on at

    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 

  • m3ngi3 Profile Picture
    725 on at

    Sorry! The mobile experience of this forum is killing me...

     

    Get file
    [PORTALURL].powerappsportals.com/_api/[ENTITY INTERNAL NAME IN PLURAL]/?fetchXml=<fetch mapping="logical" output-format="xml-platform" version="1.0" distinct="false"><entity name="[ENTITY INTERNAL NAME]"> <attribute name="[NEW FILE TYPE COLUMN INTERNAL NAME]" /> <filter> <condition attribute="[ENTITY ID COLUMN INTERNAL NAME]" operator="eq" value="ef4c3329-6262-ec11-8f8f-000d3a2d17b3" /> </filter> </entity></fetch>
     
    Get file content:

    [PORTALURL].powerappsportals.com/_api/[ENTITY INTERNAL NAME IN PLURAL](ef4c3329-6262-ec11-8f8f-000d3a2d17b3)/[NEW FILE TYPE COLUMN INTERNAL NAME]?size=full

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Pages

#1
Jerry-IN Profile Picture

Jerry-IN 71

#2
Fubar Profile Picture

Fubar 62 Super User 2025 Season 2

#3
sannavajjala87 Profile Picture

sannavajjala87 31

Last 30 days Overall leaderboard