尝试将有效负载发送到即时推送时,ios Xtify推送api 415状态代码

时间:2012-07-20 06:02:11

标签: api push-notification push xtify http-status-code-415

我正在尝试将有效负载发送到Xtify 2.0 push api。

我尝试使用此代码从我的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];
    }

其中xids是带有一个项目的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”被我的app键替换)

使用方法POST和网址“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).

我做错了什么?

1 个答案:

答案 0 :(得分:2)

该消息表示您的API密钥不正确或已过期。确保在Xtify控制台中创建高级密钥。