所以我一直在 python 中使用请求来进行 api 调用,目前以这种方式使用它:
import requests
data = {"tag":"hello","value":"ayush"}
r = requests.post('MY URl', data)
现在我想在 swift 中实现相同类型的 post api 调用,(以最短和最简单的方式)所以你能帮忙吗
最佳答案
最简单的方法是使用 Alamofire: POST request with a simple string in body with Alamofire - 但这将需要您的项目中有一个额外的库
您也可以通过 URLRequest
/URLSession
使用 Apple 提供的内部框架“手动”完成此操作:HTTP Request in Swift with POST method
关于python - 如何在 swift 3.0 中进行 rest api post 调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42353636/