Original url error thrown on flickrservice.PhotosSearch method

Topics: Developer Forum, User Forum
Apr 20, 2009 at 9:59 AM
    I have a regular flickr account(not pro account).I am displaying images of a user in my application.For this i am using flickrservice.PhotosSearch method.I am binding the resulting photocollection to a radgrid.But i am getting an error on databinding.Here is my code

 FlickrNet.Flickr flickrservice = new FlickrNet.Flickr(apiKey, sharedSecret);
                PhotoSearchOptions objsearchoptions = new PhotoSearchOptions();
                objsearchoptions.UserId = userid;
                objsearchoptions.Extras = PhotoSearchExtras.All;
                Photos photos = flickrservice.PhotosSearch(objsearchoptions);
                dgPhotoResults.DataSource = photos.PhotoCollection;
 I am getting exception 'OriginalUrl' threw an exception of type 'System.InvalidOperationException' and page crashes.

Thanks in Advance
Joshy Abraham
Apr 27, 2009 at 8:24 AM
Are you binding the OriginalUrl to anything? If you are then obviously you can't do that as it wont let you (the user in question is also likely to be a none pro user).

You should probably be using either the MediumUrl or the ThumbnailUrl depending on the context, but without knowing more about the actual ASPX code I couldn't say any more.
Apr 27, 2009 at 12:25 PM
      Yes you are right .I used mediumurl first.Now i am using Thumbnail url.I am not binding original url.Please find the aspx code given below.

<radG:RadGrid ID="dgPhoitoResults" Skin="ViyoloBlue" AutoGenerateColumns="False"
        runat="server" Width="100%" AllowPaging="true" PageSize="10" GridLines="None">
        <MasterTableView ShowHeadersWhenNoRecords="true">
                <br />
                <p align="center">
                    No Photos could be found that match the details entered.<br />
                <br />

<RowIndicatorColumn Visible="False">
<HeaderStyle Width="20px"></HeaderStyle>

<ExpandCollapseColumn Visible="False">
<HeaderStyle Width="19px"></HeaderStyle>
              <radG:GridTemplateColumn HeaderText="Image" UniqueName="Image">
              <a href='<%# Eval("MediumUrl") %>' runat="server">
              <asp:Image ID="Image1" ImageUrl='<%# Eval("ThumbnailUrl") %>'  runat="server" /></a>
Apr 28, 2009 at 8:28 AM
Edited Apr 28, 2009 at 8:30 AM
That's strange. The only thing I can assume is that the DataSource is pulling every property of the Photo into itself, and hence throwing the exception. The only way around this would be to change the source so that OriginalUrl does not throw an exception, but instead returns null.

I'll make this change in the source. In the mean time, if you are using .Net 3.5 you could use LINQ to select only the properties you are interested in:

    Photos photos = flickrservice.PhotosSearch(objsearchoptions);
    var lPhotos = from p in photos.PhotoCollection select new {p.PhotoId, p.MediumUrl, p.ThumbnailUrl, p.Title};
    dgPhotoResults.DataSource = lPhotos;