I am currently trying to migrate my company's app over to Swift from ObjC and I am running into some issues with POST requests using the new NSURLSession
API (specifically dataTaskWithRequest:completionHandler:
). I'm simply trying to make a POST with some URL encoded params (e.g., somekey=someval&anotherkey=anotherval
) as my body. The request fails with this error when I try to send a body with the POST.
NSUnderlyingError=0x7ff20bd28b90 "The operation couldn’t be completed. (kCFErrorDomainCFNetwork error -1005.)"
Strangely, when I do not send a body, the request succeeds. This doesn't cut it for my use case as I need to send in a body with my request. Headers don't seem to matter either.
I've found a couple of GitHub/SO threads on this general subject, namely this one, but the difference being I am only making one request and I get this error.
My first thought obviously is that something is wrong in my body, but even URL encoding it doesn't seem to fix the issue.
This is my set up:
- Xcode 6.1 6A1052d
- OS X 10.10 14A389
I am trying this in a Cocoa Touch Framework project and I am encountering this error using XCTest (trying to write unit tests to start out).
Any help or guidance would be greatly appreciated. Thanks!