gpt4 book ai didi

ios - Onfido 沙箱错误 422 无法处理的实体验证

转载 作者:行者123 更新时间:2023-11-30 11:46:00 25 4
gpt4 key购买 nike

我正在尝试在 Onfido 沙箱环境中创建一个检查,当我使用 curl 或 python 代码时它工作正常,而当我使用 iOS 的 swift 执行相同的请求时,我收到错误 422。以下是已确认可在 python 中运行的代码:

def identity_check(self, applicant_id: str) -> dict:
return self._post(
'applicants/{}/checks'.format(applicant_id),
data={
'type': 'express',
'reports[][name]': 'identity',
'reports[][variant]': 'kyc',
}
)

这是给我错误 422 的 swift 代码:

 func executeCheck() {
let headers: HTTPHeaders = [
"Authorization": "Token token=\(token)",
"Accept": "application/json",
]
let parameters: [String: Any] = [
"type": "express",
"reports[][name]": "identity",
"reports[][variant]": "kyc"
]
Alamofire.request(
"https://api.onfido.com/v2/applicants/\(self.applicantId)/checks",
method: .post,
parameters: parameters,
encoding: JSONEncoding.default,
headers: headers).validate().responseJSON { (response: DataResponse<Any>) in
guard response.error == nil else {
return
}
self.saveCompletedDocumentState()
}
}

最佳答案

此特定问题与 Alamofire 的误用有关,特别是在 'reports[][name]': 'identity' 的嵌套上。您应该通过子对象进行嵌套,"reports": ["name": "identity"]

但是,启动 onfido 检查的推荐方法是在后端进行。此外,任何有关 api 的问题都可以通过 Onfido 技术支持解答:api@onfido.com

关于ios - Onfido 沙箱错误 422 无法处理的实体验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48830460/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com