Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid type for field to #22

Open
diaze331122 opened this issue May 18, 2024 · 0 comments
Open

Invalid type for field to #22

diaze331122 opened this issue May 18, 2024 · 0 comments

Comments

@diaze331122
Copy link

Hello, I hope someone can point me to the right direction. I also referred to the following resources:

I have the following code snippet:

    $api_request_body = [];
    $api_request_body["from"] = ["name" => "test", "email" => $from];
    $api_request_body["to"] = ["name" => "somename", "email" => "some_email@gmail.com"];
    $api_request_body["subject"] = $subject;
    $api_request_body["text"] = $text;


    $ci = curl_init();
    
    curl_setopt($ci, CURLOPT_URL, "https://sandbox.api.mailtrap.io/api/send/1187930");
    curl_setopt($ci, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ci, CURLOPT_ENCODING, "utf-8");
    curl_setopt($ci, CURLOPT_MAXREDIRS, 10);
    curl_setopt($ci, CURLOPT_TIMEOUT, 0);
    curl_setopt($ci, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ci, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($ci, CURLOPT_POSTFIELDS, json_encode($api_request_body));
    curl_setopt($ci, CURLOPT_HTTPHEADER, array('Authorization: Bearer '.$api_key, 'Content-Type: application/json'));

I am currently getting the error: 'invalid type for field to, expected: array, given: object'. I have attempted to changing the value to a single string, a single string declared within an array and the result varies slightly (as in: 'invalid type for field to, expected: array, given: string').

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant