IOS Swift POST help needed [SOLVED]

I’ve been trying to perform a POST request in swift and i’ve hit a roadblock. I am primarily working off of the swift project that performs a GET here:

i’m trying to modify the NSURL to add in the params line, but it docent like the “?” used relier in the string to separate the URL to the access token. the URL is:

let url = NSURL(string: ",HIGH")

making the entire function:

private func pin0h() {

let url = NSURL(string: ",HIGH")

let request = NSURLRequest(URL: url)


NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue.mainQueue()) {(response, data, error) in
if error != nil {
println("Request Error \(error.localizedDescription)")
var err: NSError?
// parse the API response
var jsonResult = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.MutableContainers, error: &err) as NSDictionary
if err != nil {
println("JSON Error \(err!.localizedDescription)")



I am getting an error with the access token:

code = 400;
error = "invalid_grant";
"error_description" = "The access token provided is invalid.";

if i remove ?params=D0,HIGH i get:

error = "Variable not found";
ok = 0;

wich indicates me token is just fine. if anyone has any suggestions I would be super grateful.


swift code for POST

good stuff @jbrodie, sorry none of us got to it before you did :slight_smile:

Thanks for sharing, code. I’m also working on Spark and Swift iOS now.