使用AFNetworking 2.0进行PUT请求

时间:2017-01-10 22:54:45

标签: objective-c web-services http afnetworking-2 put

我正在尝试发出以下PUT请求:

 NSString *url = [NSString stringWithFormat:@"https://xxxx.xxxx.xxxx/%@",orderDisplayed.lineID];
NSString *token1 = [[User sharedInstance]token];

AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
[manager.requestSerializer setValue:token1 forHTTPHeaderField:@"Authorization"];



NSDictionary *params = [[NSDictionary alloc] initWithObjectsAndKeys:
                        [orderDisplayed.interval valueForKey:@"id"], @"prescription_interval_id",
                        @1,@"prescription_auto_refill",
                        nil];
NSLog(@"PARAMS %@" , [params objectForKey:@"prescription_interval_id"]);
[manager PUT:url parameters:params

     success:^(NSURLSessionDataTask *task, id responseObject)
 {
     NSLog(@"SET REFILL SUCCEEDED");
 }
     failure:^(NSURLSessionDataTask *task, NSError *error)
 {
     NSLog(@"SET REFILL FAILED");


 }];

}

但是对于我的生活无法实现。后端需要将数据作为JSON发送,我传递的参数是字典格式。

0 个答案:

没有答案