每次运行代码时,我都会收到此错误。
SUCCESS: {
error = {
message = "Invalid request (check that your POST content type is application/x-www-form-urlencoded). If you have any questions, we can help at https://support.stripe.com/.";
type = "invalid_request_error";
};
}
我正在使用 Alamofire 来完成此任务,下面是我编写的代码。
func alamoTest(){
let headers: HTTPHeaders = [
"Authorization":"Bearer test_keyxxxxx"]
let url = "https://api.stripe.com/v1/accounts"
let params = ["managed":"true","country":"us"]
Alamofire.request(url, method: .post, parameters: params, encoding: JSONEncoding.default, headers: headers).responseJSON {(response) in
print("this is what comes out", response)
if let data = response.data {
let json = String(data: data, encoding: String.Encoding.utf8)
print("Response:\(json)")
}
}
}
最佳答案
在文档中我读到这是一个 GET 请求 - 不是对此端点的 POST 请求
https://stripe.com/docs/connect/managed-accounts
curl https://api.stripe.com/v1/accounts \
-u {PLATFORM_SECRET_KEY}: \
-d country=US \
-d managed=true
顺便说一句:你为什么不尝试使用 stripe SDK:https://stripe.com/docs/mobile/ios
关于ios - 获取 POST 内容类型错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42959859/