Wednesday, April 25, 2012

The web application at http://xxx.xx.xx.xx could not be found


I was receiving the following error when trying to call a web service externally using the IP address.

The web application at http://xxx.xx.xx.xx could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application.


Adding alternate access mappings for web application in Central Administration sorted out the issue.


Friday, April 13, 2012

Error when trying to create new Uri using value from SPListItem[“FileRef”]

I have taken over maintenance of a SharePoint solution recently deployed to SharePoint 2010 (which was previously running on SharePoint 2007).
It has a timer job that runs checks unprocessed items in a library, if it has more than 5 attachments, it proceeds to great a compressed file for these items. Within this procedure it uses the SPListItem[“FileRef”] to create a new Uri. When it does this I get the following error:

Message: Error attaching files: , Invalid URI: The format of the URI could not be determined. at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind) at …

According to the uses this was working before in SharePoint 2007. The reason it fails is because the SPListItem[“FileRef”] returns a relative url.
I have amended this to use the Encoded Abs Url, so that my code now looks like this:

lst.FileURL = item["ows_EncodedAbsUrl"].ToString();

This works.