Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am sending an email individually with MAILCHIMP without using templates, but the return comes out empty, what would be the correct way to send the request message?

-The answer returns empty and the mail does not arrive

-This is my post method

route: http://localhost:6002/api/mailchimp/message/send

"message": [
                {
                    "subject": "student", 
                    "from_email": "ingenieria@uni.edu.pe", 
                    "html":"<p>Estudia en la UNI</p>",
                    "text": "Estudia en la UNI",
                    "to":   [
                                {
                                    "email": "pedro.24@gmail.com", 
                                    "type": "to"
                                }
                            ]
                }
            ]
}

function

public function send(Request $request)
    {
        $message = $request->message;

        $mailchimp = new MailchimpTransactionalApiClient();
        $mailchimp->setApiKey(env('MAILCHIMP_KEY'));

        $response = $mailchimp->messages->send(
            [
                "message"=>$message
            ]
        );
            return response()->json($response, 200);
    }

enter image description here

PD: in another method I receive the post using templates there if it works => $respuesta = $mailchimp->messages->sendTemplate(...)

question from:https://stackoverflow.com/questions/65943820/send-new-message-mailchimp-returns-empty

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
404 views
Welcome To Ask or Share your Answers For Others

1 Answer

I realized that in the json I send it has brackets [], and it shouldn't go, it would look like this and it worked

"message": {
                    "subject": "student", 
                    "from_email": "ingenieria@uni.edu.pe", 
                    "html":"<p>Estudia en la UNI</p>",
                    "text": "Estudia en la UNI",
                    "to":   [
                                {
                                    "email": "pedro.24@gmail.com", 
                                    "type": "to"
                                }
                            ]
            }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...