This topic describes the format requirements for parameters of different data types that you enter in Alibaba Cloud CLI.
Requirements for parameter formats
Alibaba Cloud CLI provides sample code automatically generated by OpenAPI Explorer. For more information, see Generate and run CLI commands.
By default, the sample code automatically generated by OpenAPI Explorer uses the Linux-applicable parameter format. If you need to run CLI commands in other environments, adjust the parameter format accordingly.
For parameters of different data types in API operations, you must meet the following format requirements when you enter the parameter names and values in Alibaba Cloud CLI:
Case sensitivity of parameter names
Parameter names in API operations are case-sensitive. When you enter parameter names in Alibaba Cloud CLI, you must follow the capitalization conventions of the parameter names.
Case sensitivity of parameter values
The values of some parameters in API operations are not case-sensitive. However, to ensure a consistent writing style, we recommend that you follow the capitalization conventions of parameter values when you enter parameter values.
Parameter values of the INTEGER type
You can directly write values of the INTEGER
type in parameters.
aliyun ecs DescribeImages --ImageName Example_Image --Pagesize 10
Parameter values of the STRING type in API documentation
You can directly write values of the STRING
type in parameters if the values do not contain special characters such as dollar signs ($
), grave accents (`
), backslashes (\
), and space characters. If a STRING-type value contains special characters, enclose the values in single quotation marks (' '
) or double quotation marks (" "
) when you enter the values.
Common scenarios
When Alibaba Cloud CLI receives strings as parameters, it converts the special characters in strings as common characters. In Linux, macOS, or Windows PowerShell, use single quotation marks (
' '
) to enclose parameters. In Windows Shell, use double quotation marks (" "
) to enclose parameters.Without special characters:
aliyun ecs DescribeImages --ImageName Example_Image
With special characters:
Windows Command Prompt:
aliyun ecs DescribeImages --ImageName "Example Image"
Linux, macOS, and Windows PowerShell:
aliyun ecs DescribeImages --ImageName 'Example Image'
Special scenarios
When you call an ROA-style API operation, if you need to use the
--body
option to specify a string which contains escape characters or a variable as the request body, the use of quotation marks is different from that in common scenarios. In Linux, macOS, and Windows Command Prompt, use double quotation marks (" "
) to enclose parameters. In Windows PowerShell, use single quotation marks (' '
) to enclose parameters.Windows Command Prompt, Linux, and macOS:
aliyun cs PUT /clusters/<ClusterId>/nodepools/<NodepoolId> --body "{\"nodepool_info\":{\"name\":\"default-nodepool\",\"resource_group_id\":\"rg-acfmyvw3wjm\"}}"
Windows PowerShell:
aliyun cs PUT /clusters/<ClusterId>/nodepools/<NodepoolId> --body '{\"nodepool_info\":{\"name\":\"default-nodepool\",\"resource_group_id\":\"rg-acfmyvw3wjm\"}}'
List of the STRING type
If a STRING
-type parameter supports multiple values, such as ImageId
, separate the values with commas (,) and enclose the values in single quotation marks (' ') or double quotation marks (" ") when you enter the values.
Windows Command Prompt:
In Windows Command Prompt, separate the values with commas (
,
) and enclose the values with double quotation marks (" "
).aliyun ecs DescribeImages --ImageId "m-23e0o****,m-23wae****"
Linux, macOS, and Windows PowerShell:
In Linux, macOS, and Windows PowerShell, separate the values with commas (
,
) and enclose the values with single quotation marks (' '
).aliyun ecs DescribeImages --ImageId 'm-23e0o****,m-23wae****'
JSON arrays of the STRING type
To set a STRING
-type parameter to a formatted JSON array, write the values in the following formats:
Windows Command Prompt:
In Windows Command Prompt, enclose the array in brackets (
[ ]
) and enclose the brackets ([ ]) in double quotation marks (" "
). Inside the brackets ([ ]), separate the values in the array with commas (,
) and enclose each value in single quotation marks (' '
).aliyun ecs DescribeDisks --DiskIds "['d-23rss****','d-23vsi****','d-23sfq****']"
Linux, macOS, and Windows PowerShell:
In Linux, macOS, and Windows PowerShell, enclose the array in brackets (
[ ]
and enclose the brackets ([ ]) in single quotation marks (' '
). Inside the brackets ([ ]), separate the values in the array with commas (,
) and enclose each value in double quotation marks (" "
).aliyun ecs DescribeDisks --DiskIds '["d-23rssg24f","d-23vsih26x","d-23sfqfbfa"]'
JSON array lists of the STRING type
To set a STRING
-type parameter to a JSON array list, write the values in the following formats:
Windows:
In Windows Command Prompt and Windows Command Prompt, enclose the list in brackets (
[ ]
) and enclose the brackets ([ ]) in double quotation marks (" "
). Inside the brackets ([ ]), separate the arrays with commas (,
) and enclose each array in braces ({ }
). Inside each pair of braces ({ }), separate the key and value of the array with a colon (:) and enclose the key and value of the array in single quotation marks (' '
).aliyun slb AddBackendServers --LoadBalancerId 15157b19f18-cn-hangzhou-dg**** --BackendServers "[{'ServerId':'i-23g8a****'},{'ServerId':'i-23bb0****'}]"
Linux and macOS:
In Linux and macOS, enclose the list in brackets (
[ ]
) and enclose the brackets ([ ]) in single quotation marks (' '
). Inside the brackets ([ ]), separate the arrays with commas (,
) and enclose each array in braces ({ }
). Inside each pair of braces ({ }), separate the key and value of the array with a colon (:) and enclose the key and value of the array in double quotation marks (" "
).aliyun slb AddBackendServers --LoadBalancerId 15157b19f18-cn-hangzhou-dg**** --BackendServers '[{"ServerId":"i-23g8a****"},{"ServerId":"i-23bb0****"}]'
DateTime values of the STRING type
To set a STRING
-type parameter to a UTC timestamp in the ISO 8601 standard, enter the parameter values in the YYYY-MM-DDThh:mm:ssZ
format.
aliyun ecs DescribeInstanceMonitorData --InstanceId i-94ola4btx**** --StartTime 2015-11-28T15:00:00Z --EndTime 2015-11-28T18:00:00Z
Special characters
If you enter a parameter value that contains special characters, a parsing error may occur even if you enclose the value in quotation marks. To resolve this issue, enter the parameter value in the key=value
format.
Example
In the following command, Alibaba Cloud CLI cannot recognize -1/-1
as the value of PortRange
.
aliyun ecs AuthorizeSecurityGroup --SecurityGroupId 'sg-bp67acfmxazb4p****' --Permissions.1.PortRange "-1/-1" --method POST --force
To resolve this issue, replace --PortRange -1/-1
with --PortRange=-1/-1
, as shown in the following code block:
aliyun ecs AuthorizeSecurityGroup --SecurityGroupId 'sg-bp67acfmxazb4p****' --Permissions.1.PortRange=-1/-1 --method POST --force