This topic describes the format requirements for different data type fields when using the Alibaba Cloud CLI.
Parameter format requirements
Note
The Alibaba Cloud CLI offers automatic generation of CLI examples through the OpenAPI portal. For detailed instructions on specific operations, see Generate and Invoke Commands.
The CLI examples automatically generated in the OpenAPI portal use the Linux-applicable parameter format by default. If you need to execute CLI commands in other environments, please adjust the parameter format accordingly.
Alibaba Cloud CLI adheres to the following format requirements for fields of different data types in OpenAPI:
Parameter case sensitivity
OpenAPI parameters are case-sensitive, and so is the parameter input for Alibaba Cloud CLI.
Parameter value case sensitivity
While some parameter values are not case-sensitive, it is recommended to strictly distinguish the case of parameter values for consistency in writing specifications.
Integer type
Parameters designated as Integer
type in the OpenAPI document can be passed in directly.
aliyun ecs DescribeImages --ImageName Example_Image --Pagesize 10
String type
For parameters labeled as String
type in the OpenAPI document, if the parameter value does not contain special characters such as $
, `
, \
, or spaces, it can be passed in directly. Otherwise, it should be enclosed in single quotes ''
or double quotes ""
.
-
General situation
When Alibaba Cloud CLI accepts strings as parameters, it typically requires conversion of special characters in the string to general characters. In Linux, macOS, or Windows PowerShell, enclose the parameter in single quotes ''
. In the Windows command prompt, use double quotes ""
.
-
No special characters:
aliyun ecs DescribeImages --ImageName Example_Image
-
Special cases
When invoking ROA-style OpenAPI and using the --body
option to specify a string (with escape characters) or a variable as the request entity, the use of quotes differs from the general situation. In Linux, macOS, or the Windows command prompt, enclose the request parameter in double quotes ""
. In Windows PowerShell, use single quotes ''
.
String type string list
For parameters identified as String
type in the OpenAPI document that support a list of multiple values, such as an ImageId
list, the parameter format is as follows.
-
Windows command prompt:
In the Windows command prompt, separate the corresponding parameter values with commas ,
and enclose them in double quotes ""
.
aliyun ecs DescribeImages --ImageId "m-23e0o****,m-23wae****"
-
Linux/macOS/Windows PowerShell:
In Linux, macOS, or Windows PowerShell, separate the corresponding parameter values with commas ,
and enclose them in single quotes ''
.
aliyun ecs DescribeImages --ImageId 'm-23e0o****,m-23wae****'
String type JSON array
For parameters classified as String
type in the OpenAPI document that require a formatted JSON array, the parameter format is as follows.
-
Windows command prompt:
In the Windows command prompt, place all values within the outermost double quotes ""
, enclose them in square brackets []
, and separate them with commas ,
, using single quotes ''
for referencing.
aliyun ecs DescribeDisks --DiskIds "['d-23rss****','d-23vsi****','d-23sfq****']"
-
Linux/macOS/Windows PowerShell:
In Linux, macOS, or Windows PowerShell, place all values within the outermost single quotes ''
, enclose them in square brackets []
, and separate them with commas ,
, using double quotes ""
for referencing.
aliyun ecs DescribeDisks --DiskIds '["d-23rssg24f","d-23vsih26x","d-23sfqfbfa"]'
String type JSON array list
For parameters identified as String
type in the OpenAPI document that require setting the parameter value as a JSON array, the parameter format is as follows.
-
Windows:
In the Windows command prompt and Windows PowerShell, place all values within the outermost double quotes ""
, enclose them in square brackets []
. Enclose each value in the JSON array with curly braces {}
, reference them with single quotes ''
, and separate them with commas ,
. Separate keys and values within the JSON array with colons :
.
aliyun slb AddBackendServers --LoadBalancerId 15157b19f18-cn-hangzhou-dg**** --BackendServers "[{'ServerId':'i-23g8a****'},{'ServerId':'i-23bb0****'}]"
-
Linux/macOS:
In Linux and macOS, place all values within the outermost single quotes ''
, enclose them in square brackets []
. Enclose each value in the JSON array with curly braces {}
, reference them with double quotes ""
, and separate them with commas ,
. Separate keys and values within the JSON array with colons :
.
aliyun slb AddBackendServers --LoadBalancerId 15157b19f18-cn-hangzhou-dg**** --BackendServers '[{"ServerId":"i-23g8a****"},{"ServerId":"i-23bb0****"}]'
String type date
For parameters designated as String
type in the OpenAPI document that require a UTC time in ISO8601 standard, pass the time 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 encounter parsing errors during command execution after enclosing the parameter value in quotes, try adjusting the parameter format to the key=value
format to ensure correct command execution.
Example
When executing the following command, Alibaba Cloud CLI cannot recognize -1/-1
as the corresponding parameter for PortRange
.
aliyun ecs AuthorizeSecurityGroup --SecurityGroupId 'sg-bp67acfmxazb4p****' --Permissions.1.PortRange "-1/-1" --method POST --force
As shown below, modify --PortRange -1/-1
to --PortRange=-1/-1
, and the command will execute correctly.
aliyun ecs AuthorizeSecurityGroup --SecurityGroupId 'sg-bp67acfmxazb4p****' --Permissions.1.PortRange=-1/-1 --method POST --force