PUT Request using AFNetworking 2.0

288 Views Asked by At

I am trying to make the following PUT request:

 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");


 }];

}

But for the life of me cannot make it to happen. The backend needs a data to be sent as JSON, params I am passing are in a dictionary format.

0

There are 0 best solutions below