如何解决如何将 curl Plaid 请求转换为 swift
我试图在 swift 中使用 Plaid API,但似乎他们无法在 swift 中本地发出 API 请求,但是他们确实有 curl。我知道您可以快速发出 curl API 请求。
文档在 curl 中显示了这个 API 请求
curl -X POST https://sandbox.plaid.com/link/token/create -H 'Content-Type: application/json' -d '{
"client_id": "CLIENT_ID","secret": "SECRET","user": { "client_user_id": "unique-per-user",},"client_name": "Plaid App","products": ["auth"],"country_codes": ["GB"],"language": "en","webhook": "https://sample-web-hook.com","account_filters": {
"depository": {
"account_subtypes": ["checking"]
}
}
}'
我将如何将此 curl 请求转换为 swift - 特别是在 swiftUI 中。
谢谢
解决方法
这是一个非常具体的问题,在某种程度上,没有人可以为您解答。您必须自己编写代码才能在出现问题时理解和调试它。话虽如此,这里有一个关于如何发出 http post 请求的非常好的教程:
https://www.appsdeveloperblog.com/http-post-request-example-in-swift/
相关部分的开头如下:
// Prepare URL
let url = URL(string: "https://jsonplaceholder.typicode.com/todos")
guard let requestUrl = url else { fatalError() }
// Prepare URL Request Object
var request = URLRequest(url: requestUrl)
request.httpMethod = "POST"
// HTTP Request Parameters which will be sent in HTTP Request Body
let postString = "userId=300&title=My urgent task&completed=false";
显然,您需要使用 plaid 变量而不是示例。但这应该会让你开始。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。