This article explains how to resolve various errors mentioned in the succeeding sections, while attaching a file from remote clients using CLI.
Error message 1
Client error: Space <space name> not found or not authorized.
Run the following curl command on the remote client to know if you are able to retrieve the results (username, password, and base URL need to be replaced in the below command):
curl -u username:password -X GET https://<baseURL>/rest/api/latest/space
If you are using another URL within theacli.properties file and running the acli actionsgetSpacelist, you notice an error: Space 'ctmtest' not found or not authorized. Then modify the acli.properties file to work with your environment and then run the CLI actions.
Error message 2
Client error: Invalid response from server for a REST API request. Check the server is completed setup and available
You need to approach the firewall/network team and make sure the server is having a complete setup and available for a response from the server for the REST API request.
Error Message 3
Error - User is not authorized to perform the request. Response code: 401"
You need to installAPI Token Authentication for Confluencefrom Atlassian marketplace and generate API token to use it as your password in theacli.properties file. Once done, run your CLI actions.
This approach works when the confluence application is authenticated by OKTA and single sign-on is enabled.
In order for the Confluence Command Line Interface(CLI) to work with SSO, you need to have an SSO specific configuration that provides a path through the SSO for REST APIs. The only possible way is to use the third-party app API Token Authentication for Confluence that provides an SSO solution. You need to contact the SSO provider to bypass the SSO to make the required rest calls.