views:

954

answers:

2

Ok I've got a weird one, I have a SharePoint WebPart in WSS 3.0 right now that's querying Yahoo Traffic's REST interface using VB.NET and the HttpWebRequest object. However I kept getting an error message from Yahoo that was saying I'm unauthorized, upon further examination, I noticed it's passing the following URL to yahoo: http://local.yahooapis.com/MapsService/V1/trafficData?appid=&city=&state=&radius=20

The Parameters are set up as such:

Private _AppID As String

    <Personalizable(True), WebBrowsable(True), WebDisplayName("Yahoo App ID"), WebDescription("Yahoo Application ID")> _
    Public Property AppID() As String
        Get
            Return _AppID

        End Get
        Set(ByVal value As String)
            _AppID = value
        End Set
    End Property

    Private _City As String
    <Personalizable(True), WebBrowsable(True), WebDisplayName("City"), WebDescription("City")> _
    Public Property City() As String
        Get
            Return _City

        End Get
        Set(ByVal value As String)
            _City = value
        End Set
    End Property

    Private _State As String
    <Personalizable(True), WebBrowsable(True), WebDisplayName("State"), WebDescription("State")> _
    Public Property State() As String
        Get
            Return _State

        End Get
        Set(ByVal value As String)
            _State = value
        End Set
    End Property

    Private _radius As String = "-1"
    <Personalizable(True), WebBrowsable(True), WebDisplayName("Radius (in miles)"), WebDescription("Radius in Miles")> _
    Public Property Radius() As String
        Get
            If _radius = "-1" Then
                Return "20"
            Else
                Return _radius
            End If


        End Get
        Set(ByVal value As String)
            _radius = value
        End Set

End Property

And the code calling REST is as such:

        Dim Url As String = ""
        Try
            Dim aDoc As New d.DataSet
            Url = "http://local.yahooapis.com/MapsService/V1/trafficData?appid=" & Me.AppID & "&city=" & Me.City & "&state=" & Me.State & "&radius=" & Me.Radius
            Dim aRequest As n.HttpWebRequest = CType(n.HttpWebRequest.Create(Url), n.HttpWebRequest)
            Dim aResponse As n.HttpWebResponse
            aResponse = CType(aRequest.GetResponse(), n.HttpWebResponse)
            If aResponse.StatusCode <> Net.HttpStatusCode.OK Then
                Throw New Exception("Server Returned This Code" & aResponse.StatusCode.ToString() & aResponse.StatusDescription)
            End If
            aDoc.ReadXml(aResponse.GetResponseStream())
            Return aDoc
        Catch ex As Exception
            System.Diagnostics.EventLog.WriteEntry("YahooTrafficUtil", ex.Message & ex.StackTrace & Url)
            Dim aContext As System.Web.HttpContext = System.Web.HttpContext.Current
            aContext.Trace.Warn(ex.ToString() & ex.StackTrace)
            childException = ex
            Return Nothing

End Try

This is on a test server that I can't access for debugging, but my development server checks out ok, everything passes through, no problem.

The AppId, City and State Parameters are listed parameters in my SharePoint Web Part, but for some reason, despite the fact that I populate these Web parts, they pass through blank. Any ideas from the crowd? Thanks!

+1  A: 

Have you experimenting with different WebPartStorage(Storage.Personal) [this defaults to Storage.Personal] property decorations?

I have assumed that the error is on storage of the property rather than the code.

Nat
Good try and gave me more insight into the properties available for a web part, but the answer was my own stupidity this time.
tekiegreg
+1  A: 

Found it, it was actually a dumb issue with the default.master file, I finally managed to figure out how to get a Stack Dump from SharePoint whenver it fails with the "broken web part" web page and traced to its true origin. Thanks for everyone who tried tho!

tekiegreg