有没有办法在没有NSData for Json的情况下单独发布参数
这是我的代码:
NSData *jsonInputData = [NSJSONSerialization dataWithJSONObject:datDict options:NSJSONWritingPrettyPrinted error:&error];
[req setHTTPBody: jsonInputData];
而不是jsonInputData我们可以附加单个参数吗?
答案 0 :(得分:0)
NSString *params=[[NSString alloc]initWithFormat:@"mobile=%@& uid=%@ & sim_code=%@ & operator_code=%@ & operator_name=%@ & otp=%@",num,uuid,dail,dailingcode,carrier.carrierName,randomCode];
NSString *mainUrl=[NSString stringWithFormat:@"%@%@",urlLinkA,methodName];
NSURL * url = [NSURL URLWithString:mainUrl];
NSMutableURLRequest * urlRequest = [NSMutableURLRequest requestWithURL:url];
//NSString * params=[[NSString alloc]initWithFormat:@"mobile=%@",[self.reqnum text]];
NSLog(@"parameter %@",parameters);
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setHTTPBody:[parameters dataUsingEncoding:NSUTF8StringEncoding]];
NSURLSessionDataTask * dataTask =[defaultSession dataTaskWithRequest:urlRequest
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
NSLog(@"Response:%@ %@\n", response, error);
if(error == nil)
{