3

私はGETを何度も使用しました。しかし、現在の状況では、POST メソッドを使用して webService を使用する必要があります。私は多くのチュートリアルを経験しましたが、できません。パスは「http://vinipost.com/Services/Mobile_Application/wcfService.svc/logIn」で、パラメーターは「id」と「pass」です テスト用の電子メールIDは「shail@gmail.com」で、パスワードは「シャイル」

    AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:@"http://vinipost.com/Services/Mobile_Application/wcfService.svc/logIn"]];
    [httpClient setParameterEncoding:AFFormURLParameterEncoding];
    NSMutableURLRequest *request = [httpClient requestWithMethod:@"POST" path:@"http://vinipost.com/Services/Mobile_Application/wcfService.svc/logIn" parameters:@{@"id":@"shail@gmail.com",@"pass":@"shail"}];

    AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
        self.movies = [JSON objectForKey:@"logInResult"];
         NSLog(@"=========%@",self.movies); 
    } failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON) {
        NSLog(@"Request Failed with Error: %@, %@", error, error.userInfo);

}];
[operation start];

出力

=========(
        {
        msg = "Server encountered error";
    }
)

サーバー側の担当者は、catch ブロックに入ると言っているため、「msg= サーバーでエラーが発生しました」と出力されます。

4

1 に答える 1