cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
skcv
Level: Powered On

Displaying images attached to SharePoint list item return HTTP 302 and requires authentication

I am creating an app where people can offer or inquire goods and stuff inside my company. To make life easier for my co-workers we let them attach files to the list item to be used as images. Also they can select one main image which will show up in the gallery on the first screen. The URL to the main image is saved in a column and at runtime an image control is fed with the URL.

Strangely, behavior differs among browsers and also people.

IE does not work it all. When trying to retrieve the image, O365 returns an HTTP 302 and in the location header we find this:

https://contoso.sharepoint.com/sites/Marketplace/_layouts/15/Authenticate.aspx?Source=%2Fsites%2FIntranet%2FLists%2FMarketplace%2FAttachments%2F9%2Foffice-620817_1920.jpg

(I switched the subdomain for anonymizing purposes).

As you can see, SharePoint requires me to authenticate which is quite dull, because I am using the PowerApp and should be autheticated against Office 365.

Is there anything I am doing wrong?

7 REPLIES 7
Community Support Team
Community Support Team

Re: Displaying images attached to SharePoint list item return HTTP 302 and requires authentication

Hi @skcv ,

Could you please share more details about the error message within your app?

How do you retrieve the image within your app? Could you please share a bit more about the formula?

Further, could you please show more details about the URL you saved in your SP List? Which type column do you use to store the URL?

 

Please consider re-create a new connection to your SP List and Office 365 connnection from your app, then try your formula again, check if the issue is solved.

 

As an alternative soution, you could consider use the Attachments control to attach image files into your SP List Item. Within the Edit form of your app, you could enable the "Attachment" field. Then you could use the Attachments control to upload images to your SP List Item.

Please check and see if the following blog would help in your scenario:

https://powerapps.microsoft.com/en-us/blog/add-attachments-to-sharepoint-lists/

 

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
skcv
Level: Powered On

Re: Displaying images attached to SharePoint list item return HTTP 302 and requires authentication

Hello, @v-xida-msft, thank you for your reply,

as stated in my initial post, when I open my PowerApp I find a gallery that has image controls. When IE tries to load the images for each gallery entry it receives an HTTP 302 and the URL in the location header of the response points to

https://tenant.sharepoint.com/sites/Marketplace/_layouts/15/Authenticate.aspx?Source=%2Fsites%2FMarketplace%2FLists%2FMarketplace%2FAttachments%2F14%2FIMG_1869%20%281%29.JPG

When I view the response in IE's developer tools I am presented with an HTML page. Of course PowerApps cannot render said HTML in an image tag so nothing at all is shown.
Any image shown there must first be attached to the list item via attachment control - we provide the end user with that. Afterwards the end user can select a main image via a list box control whose URL is then stored in a single line text column. We first tried to use the URL/Image column type but it appears this one cannot be updated from PowerApps, unfortunately (or rather: we couldn't make it work).
I will now try to export and re-import the app, maybe this will solve the issue.

skcv
Level: Powered On

Re: Displaying images attached to SharePoint list item return HTTP 302 and requires authentication

Re-importing did not help - now I even have the problem that I cannot see images in my Chrome development session. Is there any way I can force the data source confirmation prompt to re-appear? This didn't happen neither in IE nor Chrome nor Firefox on the attempt to launch the re-imported app for the first time. In Edge it works, though.

Furthermore in Firefox I receive

XML-Processing error: Could not find root element Address: https://api.powerapps.com/api/invoke row 1, column 1:

Chrome gives me an HTTP 400 in gallery.js:

GET https://tenant.sharepoint.com/_forms/default.aspx?ReturnUrl=%2fsites%2fMarketplace%2f_layouts%2f15%2fAuthenticate.aspx%3fSource%3d%252Fsites%252FMarketplace%252FLists%252FMarketplace%252FAttachments%252F5%252F2018%252DFashion%252DBicycle%252DClassical%252DCity%252DBike%252D700%252Dcc%252DVintage%252DBicycle%252Ejpg&Source=cookie 400

I am thinking of filing a ticket with Microsoft.
Thank you for your help.

skcv
Level: Powered On

Re: Displaying images attached to SharePoint list item return HTTP 302 and requires authentication

@v-xida-msft 
To elaborate further on your questions:

- I do not receive an error message in PowerApps, solely when I use the developer tools I find that when the browser requests the images it receives an HTTP 302 and in the location header I find somethin similar to

https://tenant.sharepoint.com/sites/Marketplace/_layouts/15/Authenticate.aspx?Source=%2Fsites%2FMarketplace%2FLists%2FMarketplace%2FAttachments%2F14%2FIMG_1869%20%281%29.JPG

(Please note the Authenticate.aspx page)

- I retrieve the image using an image control and binding its default to

ThisItem.MainImageURL

the URL is stored in a single text column, this works absolutely fine

- The result stored in the single text column looks like this:

https://tenant.sharepoint.com/sites/Marketplace/Lists/Marketplace/Attachments/1/inachis_io_1j.jpg

- To update the URL in my edit form I use a context variable which retrieves the URL from a ListBox control that mirrors the attachments of the list item. This means images must first be attached to the list item via the attachments control and can then be selected as main image.

I hope this clarifies things a little further. Thank you for your help.

Super User
Super User

Re: Displaying images attached to SharePoint list item return HTTP 302 and requires authentication

The default Attachments column works best. It is easy to add and remove from and super easy to make that data display in the app. I usually put a gallery that list the attachments and have were they can View the attachment in the app and I put a button that allows them to download the attachment if that is needed. 

 

See attached is just one example of how you can lay it out...tons of options though.

skcv
Level: Powered On

Re: Displaying images attached to SharePoint list item return HTTP 302 and requires authentication

@rebeccas 

Thank you for your reply and your suggestions. Unfortunately I am required to give my clients the functionality  to select a main image from their attachments.
In general, my solution works, it just does not work under certain conditions. I recently figured out, if I embed the PowerApp in a SharePoint site I do not have the authentication problems I described previously.

Super User
Super User

Re: Displaying images attached to SharePoint list item return HTTP 302 and requires authentication

I don't know for certain this is your issue BUT when I do an app that is tied to a SharePoint Library I get a similar error and to avoid this I have a pretty simple Flow I build...I am thinking it is something similar you are needing. I would try and see if this is your solution. Look at this video and the Flow to do is about 11 minutes in:

 

https://www.youtube.com/watch?v=s3PC7tqqoI4

 

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

SecondImage

PowerApps Monthly Community Call

Next Wednesday, September 18th at 8am PDT

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Users Online
Currently online: 132 members 3,948 guests
Please welcome our newest community members: