我正在发送像
这样的html字符串summary = "<p align=\"right\" style=\" \"><u><b><font face=\".SF UI Text\" style=\" font-size:16px; color:rgb(0,0,0); \" >Paras</font></b></u></p>"
作为POST参数,但请求每次都失败。 此请求字典由AFNetworking转换为json字符串,如
"summary" : "<p align=\"right\" style=\" \"><u><b><font face=\".SF UI Text\" style=\" font-size:16px; color:rgb(0,0,0); \" >Paras<\/font><\/b><\/u><\/p>"
我认为可能存在问题,但我不确定。 我不知道为什么只有当我将参数作为html字符串发送时,请求才会失败。
[requestDict setObject:htmlString forKey:@"summary"];
按上述方式设置请求字典
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
[manager.requestSerializer setTimeoutInterval:60.0];
manager.requestSerializer = [AFJSONRequestSerializer serializer];
if ([[NSUserDefaults standardUserDefaults] objectForKey:@"accessToken"] != nil)
{
// NSLog(@"%@", [[NSUserDefaults standardUserDefaults] objectForKey:@"accessToken"]);
[manager.requestSerializer setValue:requestAuthorization forHTTPHeaderField:@"Authorization"];
}
// NSLog(@"%@", requestAuthorization);
[manager.requestSerializer setValue:@"guest" forHTTPHeaderField:@"user_type"];
[manager.requestSerializer setValue:@"gzip" forHTTPHeaderField:@"Accept-Encoding"];
[manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[manager.requestSerializer setValue:[[[UIDevice currentDevice] identifierForVendor] UUIDString] forHTTPHeaderField:@"device_id"];
[manager.requestSerializer setValue:[[UIDevice currentDevice] systemVersion] forHTTPHeaderField:@"device_os"];
[manager.requestSerializer setValue:[[UIDevice currentDevice] systemName] forHTTPHeaderField:@"device_name"];
[manager POST:url parameters:parameters success:success failure:failure];
非常感谢任何帮助。 感谢
答案 0 :(得分:0)
NSString * htmlstring =[NSString stringWithFormat:@"<p align=\"right\" style=\" \"><u><b><font face=\".SF UI Text\" style=\" font-size:16px; color:rgb(0,0,0); \" >Paras</font></b></u></p>"];
NSString *strRequetURL = [NSString stringWithFormat:@"url"];
[[AFHTTPRequestSerializer serializer] setTimeoutInterval:30];
[[AFHTTPRequestOperationManager manager] POST:strRequetURL parameters:dictParameter success:^(AFHTTPRequestOperation *operation, id responseObject) {
completion(responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"error %@",error.description);
// DisplayAlert(@"Network Connection Timed Out");
}];
请使用此代码,让我知道你得到了什么