Parse.com 集成给出 Bad request 错误
Parse.com Integration gives Bad request error
在我的网络管理员中,我必须集成 Parse.com 推送通知以将推送通知发送给订阅者。
我的问题是
Do i need to integrate REST APIs with curl in my asp.net admin? or
there is any other standard C# SDK to implement?
如果答案是 REST Api,那么与 REST api 集成的文档有以下示例。
curl -X POST \
-H "X-Parse-Application-Id: " \
-H "X-Parse-REST-API-Key: " \
-H "Content-Type: application/json" \
-d '{"score":1337}' \
我已经开始通过设置测试控制台应用程序来测试 url 来集成 REST API。我开发的应用程序有以下代码。
class Program
{
private const string URL = "https://api.parse.com/1/classes/GameScore";
private const string DATA = @"{""score"":1337";
static void Main(string[] args)
{
Program.CreateObject();
Console.ReadLine();
}
private static void CreateObject()
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URL);
request.Method = "POST";
request.ContentType = "application/json";
request.Headers.Add("X-Parse-Application-Id", "My Application ID given in example");
request.Headers.Add("X-Parse-REST-API-Key", "the api key given in example");
request.ContentLength = DATA.Length;
StreamWriter requestWriter = new StreamWriter(request.GetRequestStream(), System.Text.Encoding.ASCII);
requestWriter.Write(DATA);
requestWriter.Close();
try
{
WebResponse webResponse = request.GetResponse();
Stream webStream = webResponse.GetResponseStream();
StreamReader responseReader = new StreamReader(webStream);
string response = responseReader.ReadToEnd();
Console.Out.WriteLine(response);
responseReader.Close();
}
catch (Exception e)
{
Console.Out.WriteLine("-----------------");
Console.Out.WriteLine(e.Message);
}
}
}
代码给出了一个400 Bad request错误
我不明白我错过了什么。
提前致谢
DATA 缺少右大括号。
在我的网络管理员中,我必须集成 Parse.com 推送通知以将推送通知发送给订阅者。
我的问题是
Do i need to integrate REST APIs with curl in my asp.net admin? or there is any other standard C# SDK to implement?
如果答案是 REST Api,那么与 REST api 集成的文档有以下示例。
curl -X POST \
-H "X-Parse-Application-Id: " \
-H "X-Parse-REST-API-Key: " \
-H "Content-Type: application/json" \
-d '{"score":1337}' \
我已经开始通过设置测试控制台应用程序来测试 url 来集成 REST API。我开发的应用程序有以下代码。
class Program
{
private const string URL = "https://api.parse.com/1/classes/GameScore";
private const string DATA = @"{""score"":1337";
static void Main(string[] args)
{
Program.CreateObject();
Console.ReadLine();
}
private static void CreateObject()
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URL);
request.Method = "POST";
request.ContentType = "application/json";
request.Headers.Add("X-Parse-Application-Id", "My Application ID given in example");
request.Headers.Add("X-Parse-REST-API-Key", "the api key given in example");
request.ContentLength = DATA.Length;
StreamWriter requestWriter = new StreamWriter(request.GetRequestStream(), System.Text.Encoding.ASCII);
requestWriter.Write(DATA);
requestWriter.Close();
try
{
WebResponse webResponse = request.GetResponse();
Stream webStream = webResponse.GetResponseStream();
StreamReader responseReader = new StreamReader(webStream);
string response = responseReader.ReadToEnd();
Console.Out.WriteLine(response);
responseReader.Close();
}
catch (Exception e)
{
Console.Out.WriteLine("-----------------");
Console.Out.WriteLine(e.Message);
}
}
}
代码给出了一个400 Bad request错误
我不明白我错过了什么。
提前致谢
DATA 缺少右大括号。