Mike
Mike

Reputation: 980

sending POST to php server not working

My iOS dev is sending a POST request from iOS to our API (which is processed with some PHP and looks for $_POST). However, on the API end, it's seeing the POST as empty. And instead, it's seeing the data as GET. Any ideas?

On my end, I'm simply checking if $_POST is not empty...

if(!empty($_POST)) {
    // process request
} else {
    // POST is empty
}

Here is the code my iOS dev is using.

NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:CREATE_USER_URL, SERVER_KEY, usernameFormatted, emailFormatted, passwordFormatted]];

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:@"POST"];
NSString *guid = [[NSProcessInfo processInfo] globallyUniqueString];

[SMServiceConnection makeRequest:request
                       requestor:requestor
                        callback:callback
                             guid:guid];

Upvotes: 1

Views: 117

Answers (1)

eik
eik

Reputation: 4600

You're not setting the POST body, try [NSMutableURLRequest setHTTPBody:] with some data you like to send to the server.

Upvotes: 1

Related Questions