[GH-ISSUE #99] Uber Request Post Fails with operation couldn’t be completed. (NSURLErrorDomain error -1012.) #62

Closed
opened 2026-03-03 16:45:19 +03:00 by kerem · 0 comments
Owner

Originally created by @sephethus on GitHub (Aug 26, 2015).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/99

I can get product ID's from the request back but I get this error when trying to post a request to the sandbox schedule a ride. Anybody run into this before?

Error Domain=NSURLErrorDomain Code=-1012 "The operation couldn’t be completed. (NSURLErrorDomain error -1012.)" UserInfo=0x7f8c13939ed0 {NSErrorFailingURLStringKey=https://sandbox-api.uber.com/v1/requests, NSUnderlyingError=0x7f8c0ac78410 "The operation couldn’t be completed. (kCFErrorDomainCFNetwork error -1012.)", NSErrorFailingURLKey=https://sandbox-api.uber.com/v1/requests}
    func performPostUberRequest(url: NSURL, prodId: String) {
        let params:[String: AnyObject] = [
            "start_latitude" : "39.955715",
            "start_longitude" : "-75.1680298",
            "end_latitude" : "39.9542675",
            "end_longitude" : "-75.1409609",
            "product_id": prodId
        ]

        var error: NSError?
        var request: NSMutableURLRequest = NSMutableURLRequest(URL: url)
        request.HTTPMethod = "POST"
        request.addValue("Bearer \(uberToken)", forHTTPHeaderField: "Authorization")
        request.addValue("application/json", forHTTPHeaderField: "Content-Type")
        request.HTTPBody = NSJSONSerialization.dataWithJSONObject(params, options: NSJSONWritingOptions.allZeros, error: &error)
        NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue.mainQueue()){
            response, data, error in
            if let error = error {
                println(error)
            } else if data != nil {
                if let json: NSDictionary = NSJSONSerialization.JSONObjectWithData(data, options: nil, error: nil) as? NSDictionary {
                    println(json)
                }
            }
        }
    }
Originally created by @sephethus on GitHub (Aug 26, 2015). Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/99 I can get product ID's from the request back but I get this error when trying to post a request to the sandbox schedule a ride. Anybody run into this before? ``` Error Domain=NSURLErrorDomain Code=-1012 "The operation couldn’t be completed. (NSURLErrorDomain error -1012.)" UserInfo=0x7f8c13939ed0 {NSErrorFailingURLStringKey=https://sandbox-api.uber.com/v1/requests, NSUnderlyingError=0x7f8c0ac78410 "The operation couldn’t be completed. (kCFErrorDomainCFNetwork error -1012.)", NSErrorFailingURLKey=https://sandbox-api.uber.com/v1/requests} ``` ``` func performPostUberRequest(url: NSURL, prodId: String) { let params:[String: AnyObject] = [ "start_latitude" : "39.955715", "start_longitude" : "-75.1680298", "end_latitude" : "39.9542675", "end_longitude" : "-75.1409609", "product_id": prodId ] var error: NSError? var request: NSMutableURLRequest = NSMutableURLRequest(URL: url) request.HTTPMethod = "POST" request.addValue("Bearer \(uberToken)", forHTTPHeaderField: "Authorization") request.addValue("application/json", forHTTPHeaderField: "Content-Type") request.HTTPBody = NSJSONSerialization.dataWithJSONObject(params, options: NSJSONWritingOptions.allZeros, error: &error) NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue.mainQueue()){ response, data, error in if let error = error { println(error) } else if data != nil { if let json: NSDictionary = NSJSONSerialization.JSONObjectWithData(data, options: nil, error: nil) as? NSDictionary { println(json) } } } } ```
kerem closed this issue 2026-03-03 16:45:19 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/OAuthSwift#62
No description provided.