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

getSmtpTemplates need string true to work #75

Open
giak opened this issue Feb 15, 2019 · 7 comments
Open

getSmtpTemplates need string true to work #75

giak opened this issue Feb 15, 2019 · 7 comments

Comments

@giak
Copy link

giak commented Feb 15, 2019

need to set as parameter 1 or 0 instead true / false as string in GET.

WORK with templateStatus=true
https://api.sendinblue.com/v3/smtp/templates?templateStatus=true&limit=50&offset=0
DONT WORK with templateStatus=1
https://api.sendinblue.com/v3/smtp/templates?templateStatus=1&limit=50&offset=0

@Spensolin
Copy link

Same issue here

Exception when calling SMTPApi->getSmtpTemplates: [400] Client error: GET https://api.sendinblue.com/v3/smtp/templates?templateStatus=1&limit=50&offset=0` resulted in a 400 Bad Request response: {"code":"invalid_parameter","message":"Template status should be either true or false"}`

It's look like:
ObjectSerializer::toQueryValue($templateStatus);
is causing the problem because is casting the boolean to string.

@rajatsib
Copy link
Contributor

Hi @giak

The API expects template status to be a boolean value.
Please set the templateStatus to true instead of 1.

@psaikali
Copy link

psaikali commented Mar 8, 2021

The issue here is located in the PHP API, not @giak code: ->getSmtpTemplates( true, 500 ) results in:

[400] Client error: `GET https://api.sendinblue.com/v3/smtp/templates?templateStatus=1&limit=500&offset=0&sort=desc` resulted in a `400 Bad Request` response:\n
           {"code":"invalid_parameter","message":"Template status should be either true or false"}\n
           """,

@Spensolin is right, the ObjectSerializer::toQueryValue($templateStatus) call is probably in cause here.

@pierrre
Copy link

pierrre commented Mar 8, 2021

@pierrre pierrre reopened this Mar 8, 2021
@flavioski
Copy link

Hi,
as a workaround you could pass "true" with quotes and even is not a logic solution (because its a string, not a bool) code is working.

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// ...
// ...

$templateStatus = "true";   //<---  "true" (string) and not true (bool)
$limit = 50;
$offset = 0;
$sort = "desc";

try {
    $result = $apiInstance->getSmtpTemplates($templateStatus, $limit, $offset, $sort);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling TransactionalEmailsApi->getSmtpTemplates: ', $e->getMessage(), PHP_EOL;
}
?>

@jeroennoten
Copy link

jeroennoten commented Jun 17, 2021

The DocBlock is incorrect, it says that it expects a boolean, however that will not work, so this should be a string. This is the right change to fix this:

-     * @param  bool $templateStatus Filter on the status of the template. Active &#x3D; true, inactive &#x3D; false (optional)
+     * @param  string $templateStatus Filter on the status of the template. Active &#x3D; true, inactive &#x3D; false (optional)

Or as an alternative, booleans should be converted to true and false instead of 1 and 0 when used in query strings. In that case, a change in the method ObjectSerializer::toString() could solve this.

@corsacca
Copy link

This is still an issue today.

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

8 participants