I want to Connect iOS with Drupal . I want to create node . In which i am getting session name and session id at time of login . And After I am setting on cookies . And Afterward my response is CSRF Validation Failed. I am newer in iOS. Please Help . thanks in Advance.
NSMutableURLRequest *request =[NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://example.com/services/node"]];
[request setHTTPMethod:@"POST"];
appDeleGate =(AppDelegate *)[[UIApplication sharedApplication]delegate];
NSLog(@"%@",appDeleGate.token);
[request addValue:appDeleGate.token forHTTPHeaderField:@"X-CSRFToken"];
//Cookie: {session_name}={session_id}
NSString *cookie= [NSString stringWithFormat:@"{%@}={%@}",appDeleGate.session_name,appDeleGate.sessid];
NSLog(@"%@",cookie);
[request addValue:cookie forHTTPHeaderField:@"Cookie"];
//[request setValue:cookie forKey:@"Cookie"];
NSString *post =[[NSString alloc] initWithFormat:@"type=%@&title=%@",@"charity",@"aas"];
[request setHTTPBody:[post dataUsingEncoding:NSUTF8StringEncoding]];
NSLog(@"%@",request);
NSURLResponse *response;
NSError *err;
NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&err];
if (responseData) {
NSDictionary *loginResponseDict=[NSJSONSerialization JSONObjectWithData:responseData options:0 error:&err];
NSLog(@"%@",loginResponseDict);
}