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

Crating an Apex Redirect via the PHP Library throws a "Domains must be an array" error #49

Open
deriknelvaimo opened this issue Jun 6, 2024 · 0 comments
Labels

Comments

@deriknelvaimo
Copy link

deriknelvaimo commented Jun 6, 2024

Version

5.3.0

What happened

Trying to add Apex redirects to a service throws a "Domains must be an array" error even when domains are an array.
I am using this guide: https://www.fastly.com/documentation/reference/api/vcl-services/apex-redirect/

Sample Code (sensitive bits removed):

<?php

require_once(__DIR__ . '/vendor/autoload.php');
ini_set('display_errors', 0);

$config = Fastly\Configuration::getDefaultConfiguration()->setApiToken('REDACTED');
$apiInstance = new Fastly\Api\ApexRedirectApi(null, $config);

$options = [
    'service_id' => 'REDACTED',
    'version_id' => 1,
    'domains' => [
        'example.com' // redacted real domain
    ],
    'status_code' => 301,
    'feature_revision' => 1,
];

try {
    $result = $apiInstance->createApexRedirect($options);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling ApexRedirectApi->createApexRedirect: ', $e->getMessage(), PHP_EOL;
    print_r($options);
}

Returns:

Exception when calling ApexRedirectApi->createApexRedirect: [400] Client error: `POST https://api.fastly.com/service/REDACTED/version/1/apex-redirects` resulted in a `400 Bad Request` response:
{"msg":"Bad request","detail":"Domains must be an array"}

With Options Array:

Array
(
    [service_id] => REDACTED
    [version_id] => 1
    [domains] => Array
        (
            [0] => example.com //redacted real domain
        )

    [status_code] => 301
    [feature_revision] => 1
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant