Error:Request failed: bad request (400) afnetworking batch in swift
Error:Request failed: bad request (400) afnetworking batch in swift
我正在尝试通过 swift 批量将通知推送到我的应用程序。我正在尝试通过 swift 转换下面此站点中的 curl 命令,以便我可以通过 swift:
从批处理中请求推送通知
https://batch.com/doc/api/transactional.html
这是我在 swift 中的尝试:
let manager = AFHTTPRequestOperationManager()
manager.requestSerializer.setValue("REST API KEY", forHTTPHeaderField: "X-Authorization")
manager.requestSerializer.setValue("application/json", forHTTPHeaderField: "Content-Type")
var param: [String:AnyObject] = [
"group_id": "welcome",
"recipients": [
"tokens": ["USER_TOKEN"]
],
"message": [
"title": "Hello",
"body": "Hi!"
],
"custom_payload": "{\"tag\":\"wake up push\", \"landing_screen\":\"greeting\"}",
"sandbox":true
]
manager.POST( "https://api.batch.com/1.0/"API KEY"/transactional/send",
parameters: param,
success: { (operation: AFHTTPRequestOperation!,responseObject: AnyObject!) in
print("Push Notification Successfully sent!")
print("JSON:" + responseObject.description)
},
failure: { (operation: AFHTTPRequestOperation!,error: NSError!) in
print("Error:" + error.localizedDescription)
})
我一直收到错误消息:
Error:Request failed: bad request (400)
欢迎任何 Ideas/Directions 谢谢!
你最好使用这个 Swift client for the Batch.com Transactional API。
此 API 的所有 HTTP 响应错误代码都在 the documentation 中进行了解释,但不应发生 400 错误请求错误,它一定是 Batch.com 上的临时错误结束。
我想你已经用有效值替换了 REST API KEY
、USER_TOKEN
和 API KEY
?
我正在尝试通过 swift 批量将通知推送到我的应用程序。我正在尝试通过 swift 转换下面此站点中的 curl 命令,以便我可以通过 swift:
从批处理中请求推送通知https://batch.com/doc/api/transactional.html
这是我在 swift 中的尝试:
let manager = AFHTTPRequestOperationManager()
manager.requestSerializer.setValue("REST API KEY", forHTTPHeaderField: "X-Authorization")
manager.requestSerializer.setValue("application/json", forHTTPHeaderField: "Content-Type")
var param: [String:AnyObject] = [
"group_id": "welcome",
"recipients": [
"tokens": ["USER_TOKEN"]
],
"message": [
"title": "Hello",
"body": "Hi!"
],
"custom_payload": "{\"tag\":\"wake up push\", \"landing_screen\":\"greeting\"}",
"sandbox":true
]
manager.POST( "https://api.batch.com/1.0/"API KEY"/transactional/send",
parameters: param,
success: { (operation: AFHTTPRequestOperation!,responseObject: AnyObject!) in
print("Push Notification Successfully sent!")
print("JSON:" + responseObject.description)
},
failure: { (operation: AFHTTPRequestOperation!,error: NSError!) in
print("Error:" + error.localizedDescription)
})
我一直收到错误消息:
Error:Request failed: bad request (400)
欢迎任何 Ideas/Directions 谢谢!
你最好使用这个 Swift client for the Batch.com Transactional API。
此 API 的所有 HTTP 响应错误代码都在 the documentation 中进行了解释,但不应发生 400 错误请求错误,它一定是 Batch.com 上的临时错误结束。
我想你已经用有效值替换了 REST API KEY
、USER_TOKEN
和 API KEY
?