我試圖發送一個有效載荷到Xtify 2.0推送api。ios Xtify當試圖發送一個有效載荷到即時推送時推送api 415狀態碼
我來自我的iOS應用程序使用此代碼嘗試:
- (void)sendPushToXids:(NSMutableArray *)xids {
ASIFormDataRequest *req = [[ASIFormDataRequest alloc] initWithURL:[NSURL URLWithString:xtifyPushUrl]];
req.requestMethod = @"POST";
[req setPostValue:xAppKey forKey:@"appKey"];
[req setPostValue:xApiKey forKey:@"apiKey"];
[req setPostValue:xids forKey:@"xids"];
NSMutableDictionary *contentDict = [[NSMutableDictionary alloc] init];
[contentDict setObject:@"This is a message" forKey:@"message"];
[contentDict setObject:@"default.caf" forKey:@"sound"];
[req setPostValue:contentDict forKey:@"content"];
req.delegate = self;
[req startAsynchronous];
}
其中的Xid是一個項目一個的NSMutableArray。
而且我嘗試使用此代碼使用Firefox插件REST客戶: 標題:
Content-type: application/json
數據:
{
"apiKey": "myapikey",
"appKey": "myappkey",
"xids": ["500865a987242167c69b4e6c"],
"content": {
"subject": "Greetings Earthlings",
"message": "Take me to your leader"
}
}
(在我的 「myapikey」 和 「myappkey」 被替換爲我的應用程序鍵)
用方法POST和url「http://api.xtify.com/2.0/push」
在這兩種情況下,Xtify迴應:
HTTP Status 415 - Unsupported Media Type
type Status report
message Unsupported Media Type
description The server refused this request because the request entity is in a format not supported by the requested resource for the requested method (Unsupported Media Type).
我在做什麼錯?
好的,我錯過了內容類型的標題。但是現在我得到了400個授權。任何幫助? – user1078065 2012-07-20 09:58:26