Reputation: 95
So, I'm able to send emails with Sendgrid just fine. My API key is set to "full access."
But whenever I try to interact with my contactdb (adding a contact, getting a list...anything), I get an "access forbidden" error.
require_once 'config.php';
require '../sendgrid-php/sendgrid-php.php';
$sendgrid = new \SendGrid(SENDGRID_API_KEY);
try {
$response = $sendgrid->client->contactdb()->lists()->get();
print $response->statusCode() . "\n";
print_r($response->headers());
print $response->body() . "\n";
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}
Any idea why this is happening or more importantly, what the fix is?
Upvotes: 0
Views: 497
Reputation: 11
I just spent an hour figuring this out. They haven't updated the docs. That's all. They have a new Marketing API that does not reflect the documentation. See more here
Meanwhile, you can try again with marketing()
instead of contactdb()
$response = $sendgrid->client->marketing()->lists()->get();
Upvotes: 1