これが正常な場合は申し訳ありませんが、AFNetworking を使用して iOS から投稿リクエストを送信しようとしています。Charles を使用してリクエストを監視すると、GET が送信されていることがわかります。
GET /api/updateTeamAlert/ HTTP/1.1
Host: www.******r.co
Accept-Encoding: gzip, deflate
Accept: */*
Accept-Language: en;q=1, fr;q=0.9, de;q=0.8, ja;q=0.7, nl;q=0.6, it;q=0.5
Connection: keep-alive
User-Agent: ****** Alerts/1.0 (iPhone Simulator; iOS 6.1; Scale/2.00)
これは正常ですか?サーバーで POST パラメータが空である理由を調べようとしています - これが原因でしょうか?
私は次のようにリクエストを作成しています:
NSDictionary *params = @{@"device_id":@"test-device", @"innings":@6, @"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);
}];
アップデート
まあ、これを機能させるために私がしなければならなかったのは、postPathを変更して末尾の「/」を含めることだけでした-おそらくこれはほとんどの人にとって明らかですが、受け入れられた答えの説明が欲しいです.