当我登录到betfair时,我得到了INPUT_VALIDATION_ERROR。我正在跟踪这些文档,但是对于这个特定的错误代码来说,这是没有用的。
如果有人能引导我朝正确的方向前进,我将不胜感激。
这是我的快速密码
let request = NSMutableURLRequest(URL: NSURL(string: "https://identitysso.betfair.com/api/login")!)
request.HTTPMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Accept")
request.setValue("MY_APP_KEY", forHTTPHeaderField: "X-Application")
let postString = "username=MY_USER_NAME&password=MY_PASSWORD"
request.HTTPBody = postString.dataUsingEncoding(NSUTF8StringEncoding)
let task = NSURLSession.sharedSession().dataTaskWithRequest(request) { data, response, error in
guard error == nil && data != nil else { // check for fundamental networking error
print("error=\(error)")
return
}
if let httpStatus = response as? NSHTTPURLResponse where httpStatus.statusCode != 200 { // check for http errors
print("statusCode should be 200, but is \(httpStatus.statusCode)")
print("response = \(response)")
}
let responseString = NSString(data: data!, encoding: NSUTF8StringEncoding)
print("responseString = \(responseString)")
}
task.resume()发布于 2017-08-04 11:00:55
我认为您需要将Content-Type的头设置为
application/x-www-form-urlencodedHttp头中的三个参数:
httpRequest.setHeader("Accept", "application/json");
httpRequest.setHeader("Content-Type", "application/x-www-form-urlencoded");
httpRequest.setHeader("X-Application", <apiKey>);https://stackoverflow.com/questions/38742866
复制相似问题