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':'the api key','notifications':[ { 'send_date':'now', 'ignore_user_timezone': true, 'content':'Hello world' } ]}}"
Dim myUri As New URI(" https://cp.pushwoosh.com/json/1.3/ ")
Dim データ = Encoding.UTF8.GetBytes(jsonSring)
Dim result_post = MyFunctions.SendRequest(myUri, data, "application/json", "POST")
関数:
Public Shared Function 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