Sendgrid-php: Empty templates array

Created on 21 Jul 2019  路  4Comments  路  Source: sendgrid/sendgrid-php

Hi guys!

Summary

I'm trying to get all transactional templates to save their IDs but templates method returns empty array. However if I try to get template by Id, It works fine.

Steps to Reproduce

Templates method doesn't work even via console using curl, therefore I just provide curl requests.

  1. curl -X "GET" "https://api.sendgrid.com/v3/templates" -H "Authorization: Bearer MY_API_KEY" -H "Content-Type: application/json"

Returns
{"templates":[]}

  1. curl -X "GET" "https://api.sendgrid.com/v3/templates/d-cd5b73442ffc4e37bdf247abbe8d3095" -H "Authorization: Bearer MY_API_KEY" -H "Content-Type: application/json"

Returns

{"id":"d-cd5b73442ffc4e37bdf247abbe8d3095","name":"Test2","generation":"dynamic","updated_at":"2019-07-21 15:10:38","versions":[{"id":"d38d3b8a-faf6-4cef-841e-e8b7fe4e364e","user_id":11514558,"template_id":"d-cd5b73442ffc4e37bdf247abbe8d3095","active":1," .....
......

Technical details:

  • Ubuntu 18.04.2 LTS
  • curl 7.58.0 (x86_64-pc-linux-gnu) libcurl/7.58.0 OpenSSL/1.1.1c zlib/1.2.11 libidn2/2.0.4 libpsl/0.19.1 (+libidn2/2.0.4) nghttp2/1.30.0 librtmp/2.3
question

Most helpful comment

Hi @tijmenve ,

I've contacted to SendGrid support and they answered that some calls have been changed.

Please try this url - https://api.sendgrid.com/v3/templates?generations=dynamic, it works for me

   $queryParams = array('generations' => 'dynamic');
   $response = $this->getClient()->templates()->get(null, $queryParams);

All 4 comments

I'm having the exact same issue.

I'm able to get a template by id: $sendgrid->client->templates()->_($template_id)->get();

However when I try to load all templates: $response = $sendgrid->client->templates()->get();
$response->body():
This is the response body (while statusCode is 200):
"{"templates":[]}"

Hi @tijmenve ,

I've contacted to SendGrid support and they answered that some calls have been changed.

Please try this url - https://api.sendgrid.com/v3/templates?generations=dynamic, it works for me

   $queryParams = array('generations' => 'dynamic');
   $response = $this->getClient()->templates()->get(null, $queryParams);

Great, this works for me.

Thank you @atsareva!

Hello @atsareva,

Thanks for providing the solution!

With best regards,

Elmer

Was this page helpful?
0 / 5 - 0 ratings

Related issues

billizzard picture billizzard  路  5Comments

jverlee picture jverlee  路  4Comments

moontrv picture moontrv  路  3Comments

bjornmann picture bjornmann  路  3Comments

Aubynj picture Aubynj  路  3Comments