Ich habe eine IOS-Anwendung, die ich per Mandrill senden möchte. Ich habe versucht, dies zu implementieren, aber es funktioniert nicht und ich habe mich verwirrt.IOS JSON eine E-Mail von Mandrill senden
Beim Drücken der Taste eine E-Mail aus dem IOS-Anwendung senden ich log diese Fehlermeldung:
{"status":"error","code":-1,"name":"ValidationError","message":"You must specify a key value"}
Mein Code ist:
NSString *post = [NSString stringWithFormat:@"{\"key\": \"abcdefg123456\", \"raw_message\": \"From: [email protected]\nTo: [email protected]\nSubject: Some Subject\n\nSome content.}"];
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL:[NSURL URLWithString:@"https://mandrillapp.com/api/1.0/messages/send-raw.json"]];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];
NSLog(@"Post: %@", post);
NSURLResponse *response;
NSData *POSTReply = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:nil];
NSString *theReply = [[NSString alloc] initWithBytes:[POSTReply bytes] length:[POSTReply length] encoding: NSASCIIStringEncoding];
NSLog(@"Reply: %@", theReply);
Bitte lassen Sie mich wissen, wo ich falsch werde. .
Dank ich habe Ich vermisse den \ after-Inhalt und auch ein \ vor jedem \ n – Steve