request请求 HTTPBody 格式

//Json格式
 
    [mtbRequset setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    NSError *error;
    NSData *body = [NSJSONSerialization dataWithJSONObject:bodyDict options:NSJSONWritingPrettyPrinted error:&error];
    if (error) {
        MBErrorLog(@"%@", error);
    }
    mtbRequset.HTTPBody = body;
 
 
//x-www-form-urlencoded格式
    NSString *bodyStr = @"type=shentong&postid=3333557693903";
    mutablerequest.HTTPBody = [bodyStr dataUsingEncoding:NSUTF8StringEncoding];
    [mutablerequest setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
 
posted @ 2017-12-26 11:18  有棱角的圆  阅读(7872)  评论(0编辑  收藏  举报