NSURLErrorDomain Code=-1001 error when a http post request is sent

后端 未结 5 2121
慢半拍i
慢半拍i 2021-01-17 14:48

I am using the following code to post an image to my server.

@IBAction func postButtonPressed(sender: UIButton) {
    let task = NSURLSession.sharedSession(         


        
5条回答
  •  花落未央
    2021-01-17 15:13

    I fixed using headers with application/json and sending on the request:

    let headers: HTTPHeaders = [
            .accept("application/json")
    ]
    AF.request(url, method: .post, parameters: score, encoder: JSONParameterEncoder.default, headers: headers)
    

提交回复
热议问题