I successfully created a taste profile using iOS and AFNetworking but I’ve been unable to update it. I’ve tried post requests using AFNetworking (both prior version and 2.0) as well as NSURLConnection. The following shows a successful result but does not update the profile. Is there an example using AFNetworking or NSURLConnection to do an update using iOS?
NSMutableURLRequest *postRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://developer.echonest.comapi/v4/tasteprofile/update?api/v4/tasteprofile/update?api_key=xxx&id=xxx&data_type=json&format=json"]];
[postRequest setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"]; [postRequest setHTTPMethod:@"POST"];
[postRequest setValue:@"application/json; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:@"update",@"action",@"Item001",@"item_id",@"xxx",@"artist_name", nil];
NSData* jsonData = [NSJSONSerialization dataWithJSONObject:dict options:0 error:nil];
postRequest.HTTPBody = jsonData;
NSMutableData *receivedConnectionData;
NSURLConnection *thePostConnection=[[NSURLConnection alloc] initWithRequest:postRequest delegate:self];
if (!thePostConnection) {
receivedConnectionData = nil;
}
else {
NSLog(@"post success");
}