aliyun / openapi-sdk-php

Alibaba Cloud SDK for PHP
https://packagist.org/packages/alibabacloud/sdk
Other
521 stars 109 forks source link

"Message": "The specified parameter \"KeyPairNames\" is not valid." #38

Closed samoyedsun closed 5 years ago

samoyedsun commented 5 years ago

你好,我在阿里云的API可视化调试面板上使用PHP删除密钥对的时候报了一个莫名其妙的错误,我很郁闷,我觉得我的请求参数没有错,他为什么总说我填的keypairnames参数无效呢.

REQUEST: ` <?php use AlibabaCloud\Client\AlibabaCloud; use AlibabaCloud\Client\Exception\ClientException; use AlibabaCloud\Client\Exception\ServerException;

// Download:https://github.com/aliyun/openapi-sdk-php-client
// Usage:https://github.com/aliyun/openapi-sdk-php-client/blob/master/README-CN.md

AlibabaCloud::accessKeyClient('<accessKeyId>', '<accessSecret>')
                        ->regionId('cn-shenzhen')
                        ->asGlobalClient();

try {
    $result = AlibabaCloud::rpcRequest()
                        ->product('Ecs')
                        // ->scheme('https') // https | http
                        ->version('2014-05-26')
                        ->action('DeleteKeyPairs')
                        ->method('POST')
                        ->options([
                                        'query' => [
                                        'RegionId' => 'cn-shenzhen',
                                        'KeyPairNames' => 'aliyunhongkong',
                                        'SourceRegionId' => 'cn-shenzhen',
                                        ],
                                    ])
                        ->request();
    print_r($result->toArray());
} catch (ClientException $e) {
    echo $e->getErrorMessage() . PHP_EOL;
} catch (ServerException $e) {
    echo $e->getErrorMessage() . PHP_EOL;
}
<?php
use AlibabaCloud\Client\AlibabaCloud;
use AlibabaCloud\Client\Exception\ClientException;
use AlibabaCloud\Client\Exception\ServerException;

// Download:https://github.com/aliyun/openapi-sdk-php-client
// Usage:https://github.com/aliyun/openapi-sdk-php-client/blob/master/README-CN.md

AlibabaCloud::accessKeyClient('<accessKeyId>', '<accessSecret>')
                        ->regionId('cn-shenzhen')
                        ->asGlobalClient();

try {
    $result = AlibabaCloud::rpcRequest()
                        ->product('Ecs')
                        // ->scheme('https') // https | http
                        ->version('2014-05-26')
                        ->action('DeleteKeyPairs')
                        ->method('POST')
                        ->options([
                                        'query' => [
                                        'RegionId' => 'cn-shenzhen',
                                        'KeyPairNames' => 'aliyunhongkong',
                                        'SourceRegionId' => 'cn-shenzhen',
                                        ],
                                    ])
                        ->request();
    print_r($result->toArray());
} catch (ClientException $e) {
    echo $e->getErrorMessage() . PHP_EOL;
} catch (ServerException $e) {
    echo $e->getErrorMessage() . PHP_EOL;
}

`

RESPONSE: { "RequestId": "B43E020F-FDF8-4BF2-BC94-910105185959", "HostId": "ecs.aliyuncs.com", "Code": "InvalidKeyPairNames.ValueNotSupported", "Message": "The specified parameter \"KeyPairNames\" is not valid." }

ghost commented 5 years ago

你好,我在阿里云的API可视化调试面板上使用PHP删除密钥对的时候报了一个莫名其妙的错误,我很郁闷,我觉得我的请求参数没有错,他为什么总说我填的keypairnames参数无效呢.

REQUEST: ` <?php use AlibabaCloud\Client\AlibabaCloud; use AlibabaCloud\Client\Exception\ClientException; use AlibabaCloud\Client\Exception\ServerException;

// Download:https://github.com/aliyun/openapi-sdk-php-client
// Usage:https://github.com/aliyun/openapi-sdk-php-client/blob/master/README-CN.md

AlibabaCloud::accessKeyClient('<accessKeyId>', '<accessSecret>')
                        ->regionId('cn-shenzhen')
                        ->asGlobalClient();

try {
    $result = AlibabaCloud::rpcRequest()
                        ->product('Ecs')
                        // ->scheme('https') // https | http
                        ->version('2014-05-26')
                        ->action('DeleteKeyPairs')
                        ->method('POST')
                        ->options([
                                        'query' => [
                                        'RegionId' => 'cn-shenzhen',
                                        'KeyPairNames' => 'aliyunhongkong',
                                        'SourceRegionId' => 'cn-shenzhen',
                                        ],
                                    ])
                        ->request();
    print_r($result->toArray());
} catch (ClientException $e) {
    echo $e->getErrorMessage() . PHP_EOL;
} catch (ServerException $e) {
    echo $e->getErrorMessage() . PHP_EOL;
}
<?php
use AlibabaCloud\Client\AlibabaCloud;
use AlibabaCloud\Client\Exception\ClientException;
use AlibabaCloud\Client\Exception\ServerException;

// Download:https://github.com/aliyun/openapi-sdk-php-client
// Usage:https://github.com/aliyun/openapi-sdk-php-client/blob/master/README-CN.md

AlibabaCloud::accessKeyClient('<accessKeyId>', '<accessSecret>')
                        ->regionId('cn-shenzhen')
                        ->asGlobalClient();

try {
    $result = AlibabaCloud::rpcRequest()
                        ->product('Ecs')
                        // ->scheme('https') // https | http
                        ->version('2014-05-26')
                        ->action('DeleteKeyPairs')
                        ->method('POST')
                        ->options([
                                        'query' => [
                                        'RegionId' => 'cn-shenzhen',
                                        'KeyPairNames' => 'aliyunhongkong',
                                        'SourceRegionId' => 'cn-shenzhen',
                                        ],
                                    ])
                        ->request();
    print_r($result->toArray());
} catch (ClientException $e) {
    echo $e->getErrorMessage() . PHP_EOL;
} catch (ServerException $e) {
    echo $e->getErrorMessage() . PHP_EOL;
}

`

RESPONSE: { "RequestId": "B43E020F-FDF8-4BF2-BC94-910105185959", "HostId": "ecs.aliyuncs.com", "Code": "InvalidKeyPairNames.ValueNotSupported", "Message": "The specified parameter \"KeyPairNames\" is not valid." }

您好,请根据接口文档的描述传入JSON:https://help.aliyun.com/document_detail/51772.html?spm=5176.10695662.1996646101.searchclickresult.590e1ac5zDhJ46

ghost commented 5 years ago

您好,请根据接口文档的描述传入JSON:https://help.aliyun.com/document_detail/51772.html?spm=5176.10695662.1996646101.searchclickresult.590e1ac5zDhJ46