1

I am attempting to send some parameters to an API using AFNetworking. I have reduced my application code to:

NSDictionary *params = @{@"team":@"WashingtonNationals"};

[_client postPath:@"updateTeamAlert"
       parameters:params
          success:^(AFHTTPRequestOperation *operation, id responseObject)
{
    NSString *responseStr = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
    NSLog(@"Request Successful, response '%@'", responseStr);
}
          failure:^(AFHTTPRequestOperation *operation, NSError *error)
{
    NSLog(@"[HTTPClient Error]: %@", error.localizedDescription);
}];

On the server I am using the following PHP to debug:

if (isset($_POST["team"])) {
        echo "team  set ok";
    }
    else {
        echo "team not set";
    }

I am consistently receiving the 'team not set' response.

When I vardump the POST I am returned:

'array(0) {

}

(an empty array I assume)?

What am I missing?

Ben Packard
  • 26,102
  • 25
  • 102
  • 183

2 Answers2

0

I'm not sure but you might have a similar problem to: Read associative array from json in $_POST

if this is the case your data might be in php://input instead of in $_POST

Community
  • 1
  • 1
Christophe
  • 46
  • 3
0

I was missing the trailing '/' from my postPath. :/

Ben Packard
  • 26,102
  • 25
  • 102
  • 183