我正在尝试发出以下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发送,我传递的参数是字典格式。