Resolve errors while attaching a file from remote client using CLI

Problem statement

This article explains how to resolve various errors mentioned in the succeeding sections, while attaching a file from remote clients using CLI.

Environment

ApplicationConfluence
App Version9.0.0

Error message 1

Client error: Space <space name> not found or not authorized.

Solution 1

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 the acli.properties file and running the acli actions getSpacelist, you notice an error: Space 'ctmtest' not found or not authorizedThen 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

Solution 2

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"

Solution 3

You need to install API Token Authentication for Confluence from Atlassian marketplace and generate API token to use it as your password in the acli.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.