Help Center/ Koo Command Line Interface/ FAQs/ Parameters/ How Do I Use cli-jsonInput?
Updated on 2023-03-13 GMT+08:00

How Do I Use cli-jsonInput?

Background

Tools such as the command prompt (cmd.exe) have restrictions on the allowed maximum string length. If there are too many parameters in a command or the parameter values are too long, the parameters entered may be incomplete due to the length limit. In this case, use --cli-jsonInput=${jsonFileName} to pass cloud service API parameters through a JSON file. KooCLI parses and uses the parameters in the JSON file to call the target API.

Usage Description

For details about how to use cli-jsonInput, see Passing API Parameters with JSON File.

Precautions

  • The JSON file passed by using the --cli-jsonInput option supports only API parameters of cloud services and does not support system parameters. If a parameter of the target API has the same name as a new system parameter or an old system parameter, the one written into the jsonInput file is identified as an API parameter by default.
  • In the JSON file passed by using the --cli-jsonInput option, KooCLI obtains and parses the parameter value based on the key at the outermost layer of JSON. Currently, the supported keys include path, query, body, formData, header, and cookie. The content under other keys at the outermost layer of JSON will be ignored. If none of the keys at this layer is supported, the following error message is displayed:

    [USE_ERROR] The cli-jsonInput file contains invalid content. For details, see...

  • When you use the --cli-jsonInput option to pass cloud service API parameters, all API parameters in the same position must be written into a JSON file or directly passed using a command. Otherwise, the parameters may not be completely parsed, and the following error message is displayed:

    [USE_ERROR] The following parameters are required: *

  • The --cli-jsonInput option supports only JSON files with the .json extension. The maximum file size is 5 MB. When --cli-jsonInput is used, the JSON file format and the parameter types in the file are verified. If the JSON file has incorrect format, the following error message is displayed:

    [USE_ERROR]Failed to parse file for the cli-jsonInput parameter. Cause: File contains invalid parameters.

    If the JSON file contains an unsupported parameter type, the following error message is displayed:

    [USE_ERROR] Value type of * is not supported.

  • When you use the --cli-jsonInput option to pass cloud service API parameters, parameter values cannot be custom parameters.