1

我必须使用 pushwoosh api 向设备发送消息。我从 vb.net 发送它,我有一个高级帐户。该代码工作正常,但我从服务器返回代码 400。有任何想法吗?

我的 json 请求如下所示:

{   
    'request':
    {
'application':'xxxxx-xxxxx',                 
    'auth':'xxxxx',
        'notifications':[{
             'send_date':'now',     
             'ignore_user_timezone': true,     
             'content':'Hallo world'   
             }]
     }
}

VB.net 代码:

来电:

dim JsonSring = "{'request':{'application':'My app id','auth':'api key','notifications':[ {'send_date':'now','ignore_user_timezone': true, '内容':'你好世界'}]}}"

将 myUri 调暗为新 Uri(" https://cp.pushwoosh.com/json/1.3/ ")

暗淡数据 = Encoding.UTF8.GetBytes(jsonSring)

Dim result_post = MyFunctions.SendRequest(myUri, data, "application/json", "POST")

功能:

公共共享函数 SendRequest(uri As Uri, jsonDataBytes As Byte(), contentType As String, method As String) As String

    Dim req As WebRequest = WebRequest.Create(uri)

    req.ContentType = contentType

    req.Method = method

    req.ContentLength = jsonDataBytes.Length



    Dim stream = req.GetRequestStream()
    stream.Write(jsonDataBytes, 0, jsonDataBytes.Length)
    stream.Close()

    Dim response = req.GetResponse().GetResponseStream()

    Dim reader As New StreamReader(response)
    Dim res = reader.ReadToEnd()
    reader.Close()
    response.Close()

    Return res
End Function
4

1 回答 1

1

您的网址似乎不完整。会是这样吗?

Dim myUri As New Uri("https://cp.pushwoosh.com/json/1.3/")

它应该是https://cp.pushwoosh.com/json/1.3/createMessagehttps://cp.pushwoosh.com/json/1.3/registerDevice等。

于 2013-08-22T08:53:51.517 回答