我需要在密钥中传递body,email,userid和session_id。我正在使用Postman,我得到了理想的结果。但我无法在目标C中完成。我正在使用AFNetworking
这就是我想要实现的目标。
-(void)CallUpdateAPI
{
AFHTTPSessionManager *apicall = [AFHTTPSessionManager manager];
apicall.responseSerializer = [AFHTTPResponseSerializer serializer];
NSMutableDictionary *parameters2 =[[NSMutableDictionary alloc]init];
[parameters2 setObject:[[[NSUserDefaults standardUserDefaults] objectForKey:@"userlist"] objectForKey :@"userid"] forKey:@"userid"];
NSNumber *v1 = [NSNumber numberWithInt:1];
[parameters2 setValue:v1 forKey:@"act"];
[parameters2 setObject:[[[NSUserDefaults standardUserDefaults] objectForKey:@"userlist"] objectForKey :@"session_id"] forKey:@"session_id"];
[parameters2 setObject:_email.text forKey:@"email"];
NSLog(@"Server response : %@ ",parameters2);
[apicall POST:@"https://portal.blockage.io/api/v1/user/kyc_update" parameters:parameters2 progress:nil success:^(NSURLSessionTask *task, id responseObject)
{
NSError *e = nil;
NSMutableDictionary *resultFromPost2 = [NSJSONSerialization JSONObjectWithData: responseObject options: 0 error: &e];
//NSLog(@"Server response : %@ %@",resultFromPost2,e);
//...
}
//...
}
答案 0 :(得分:0)
使用合适的身体参数构建字典:
NSDictionary *bodyPArams = @{@"xxx":@"xxx",
@"xxx":@"xxx",
@"xxx":@"xxx",
@"xxx":@"xxx"};
并调用POST方法:
[apicall POST:@"https://portal.blockage.io/api/v1/user/kyc_update" parameters:bodyPArams progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
}];
答案 1 :(得分:0)
你的session_id参数是"获取"参数。您需要在网址中设置它而不是在正文中。
"https://portal.blockage.io/api/v1/user/kyc_update?session_id=YourSessionID"
您可以使用:
NSString * urlString = [NSString stringWithFormat:@"https://portal.blockage.io/api/v1/user/kyc_update?session_id=%@", [[[NSUserDefaults standardUserDefaults] objectForKey:@"userlist"] objectForKey :@"session_id"];
[apicall POST:urlString parameters:parameters2 progress:nil success:^(NSURLSessionTask *task, id responseObject)