小编Uda*_*day的帖子

获取错误"远程服务器返回错误:(400)错误请求." 在线WebResponse response = request.GetResponse();

//Create a request using a URL that can receive a post.
WebRequest request = WebRequest.Create("https://go.urbanairship.com/api/push/");
request.Credentials = new NetworkCredential("pvYMExk3QIO7p2YUs6BBkg", "rO3DsucETRadbbfxHkd6qw");

// Set the Method property of the request to POST.
request.Method = "POST";

// Create POST data and convert it to a byte array.
//WRITE JSON DATA TO VARIABLE D
string postData = "{\"aps\": {\"badge\": 1, \"alert\": \"Hello from Urban Airship!\"}, \"device_tokens\": [\"6334c016fc643baa340eca25bc661d15055a07b475e9a6108f3f644b15dd05ac\"]}";
byte[] byteArray = Encoding.UTF8.GetBytes(postData);

// Set the ContentType property of the WebRequest.
request.ContentType = "application/json";

// Set …
Run Code Online (Sandbox Code Playgroud)

c#

3
推荐指数
1
解决办法
8833
查看次数

标签 统计

c# ×1