Vb.net 400向雅虎添加联系人时出现错误请求!信息员

Vb.net 400向雅虎添加联系人时出现错误请求!信息员,vb.net,yahoo,yahoo-api,Vb.net,Yahoo,Yahoo Api,我想使用VB NET向yahoo messenger添加联系人 这是我的代码: Dim url As String = "http://developer.messenger.yahooapis.com/v1/group/{{GROUP}}/contact/yahoo/{{USER}}" url &= "?oauth_consumer_key=" & sConsumer_key url &= "&oauth_nonce=" & GetRan

我想使用VB NET向yahoo messenger添加联系人

这是我的代码:

Dim url As String = "http://developer.messenger.yahooapis.com/v1/group/{{GROUP}}/contact/yahoo/{{USER}}"
    url &= "?oauth_consumer_key=" & sConsumer_key
    url &= "&oauth_nonce=" & GetRandom(10000, 50000)
    url &= "&oauth_signature=" & sConsumer_secret & "%26" & oauth_token_secret_value
    url &= "&oauth_signature_method=PLAINTEXT"
    url &= "&oauth_timestamp=" & TimeOfDay
    url &= "&oauth_token=" & oauth_token_value
    url &= "&oauth_version=1.0"
    url &= "&sid=" & YmsgSessionID

    url = Replace(url, "{{GROUP}}", group)
    url = Replace(url, "{{USER}}", user)

    '//additional header
    Dim request As WebRequest = Nothing
    Dim webAddress As Uri
    webAddress = New Uri(url)

    ' Create the web request  
    request = DirectCast(WebRequest.Create(webAddress), HttpWebRequest)
    Dim myheaders As WebHeaderCollection

    ' set type to GET
    request.Method = "PUT"
    request.ContentType = "application/json"
    myheaders = request.Headers
    myheaders.Add("charset", "utf-8")

    '----- get response
    Dim response As WebResponse = request.GetResponse()

    Dim dataStream As Stream = response.GetResponseStream()
    Dim reader As New StreamReader(dataStream)
    Dim responseFromServer As String = reader.ReadToEnd()
当我执行它时,我在以下位置收到一个异常400错误请求:

Dim响应为WebResponse=request.GetResponse()


我尝试将相同的url与DELETE方法(
request.method=“DELETE”
)一起使用,但当我更改为PUT方法时,收到了400个错误的请求。有人有什么想法吗?

你为什么用PUT代替GET?您正在尝试上载文件吗?基于此,此url只有PUT和DELETE操作。我尝试过使用GET,它说不允许使用这种方法。