如何在asp.net中使用API​​在linkedIn中添加喜欢的内容

时间:2015-01-01 08:21:45

标签: c# asp.net vb.net

这是使用VB.NET的POST方法请帮助我有错误。我得到400错误,“远程服务器返回错误:(400)错误请求”.....我的方法如下....

Public Function Linked_DataApi_Call(ByVal RequestUrl As String) As String
    Try
        Dim request As WebRequest = WebRequest.Create(RequestUrl)
        request.Credentials = CredentialCache.DefaultCredentials               
        request.Method = "PUT"
        /*Here am getting error:"The remote server returned an error: (400) Bad Request"*/

        Dim response As WebResponse = request.GetResponse
        Console.WriteLine(CType(response, HttpWebResponse).StatusDescription)
        Dim dataStream As Stream = response.GetResponseStream
        Dim reader As New StreamReader(dataStream)
        Dim responseFromServer As String = reader.ReadToEnd
        Return responseFromServer

    Catch ex As Exception
        Return ex.Message
    End Try
End Function

0 个答案:

没有答案