How to disable customer satisfaction programmatically/ using REST API for JSM projects
Platform Notice: Data Center - This article applies to Atlassian products on the Data Center platform.
Note that this knowledge base article was created for the Data Center version of the product. Data Center knowledge base articles for non-Data Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
In this article, we will describe how to enable and disable the customer satisfaction setting using REST API for the JSM (Jira Service Management) projects.
Environment
Jira Service Management (JSM) Data Center on any version from 4.0.0.
Solution
Satisfaction setting is available for all the JSM projects under Project settings > Satisfaction settings. Users can enable and disable this setting from here via GUI.
At times, the requirement may arise to switch off and switch on this setting for multiple projects in an automated way.
To achieve this use case, we can make make use of the below REST API approaches.
Disclaimer
Please note that the below REST API endpoints are not documented and thus do not come under the Atlassian Support scope. Users should exercise caution while using them and should thoroughly test first in non-production environments before implementing in the Production Jira instances.
API call to disable the satisfaction:
Method: DELETE
Endpoint: <JIRA_BASE_URL>/rest/servicedesk/1/<PROJECT_KEY>/settings/feedback/enable
Payload: { false }
Headers: Content-type: application/json
Accept: application/json
Screenshot below for reference:
API call to enable the satisfaction:
Method: PUT
Endpoint: <JIRA_BASE_URL>/rest/servicedesk/1/<PROJECT_KEY>/settings/feedback/enable
Payload: { true }
Headers: Content-type: application/json
Accept: application/json
Screenshot below for reference:
If the requirement is to perform this same operation for multiple JSM projects, then below sample shell scripts can be used. They can be customised and can also be made more user friendly.
#!/bin/bash
# Define constants for the file name and the base URL of your endpoint
FILE_NAME="jsm_projects_list.csv"
BASE_URL="<ENTER_JIRA_BASE_URL_HERE>"
USERNAME="<ENTER_USERNAME_HERE>"
PASSWORD="<ENTER_PASSWORD_HERE>"
# Check if the file exists
if [ ! -f "$FILE_NAME" ]; then
echo "File $FILE_NAME does not exist."
exit 1
fi
# Read each line from the CSV to get the PROJECT_KEY
while IFS= read -r project_key
do
# Form the complete URL by appending the PROJECT_KEY and the remaining path
URL="${BASE_URL}/rest/servicedesk/1/${project_key}/settings/feedback/enable"
# Execute the DELETE request
response=$(curl -s -o /dev/null -w "%{http_code}" -X DELETE "$URL" \
-H "Content-type: application/json" \
-H "Accept: application/json" \
-d '{ "enabled": false }' \
-u "$USERNAME:$PASSWORD")
# Check the response code
if [ "$response" -eq 200 ]; then
echo "Successfully disabled feedback for project key: $project_key"
else
echo "Failed to disable feedback for project key: $project_key. Response code: $response"
fi
done < "$FILE_NAME"
Similarly for enable satisfaction:
#!/bin/bash
# Define constants for the file name and the base URL of your endpoint
FILE_NAME="jsm_projects_list.csv"
BASE_URL="<ENTER_JIRA_BASE_URL_HERE>"
USERNAME="<ENTER_USERNAME_HERE>"
PASSWORD="<ENTER_PASSWORD_HERE>"
# Check if the file exists
if [ ! -f "$FILE_NAME" ]; then
echo "File $FILE_NAME does not exist."
exit 1
fi
# Read each line from the CSV to get the PROJECT_KEY
while IFS= read -r project_key
do
# Form the complete URL by appending the PROJECT_KEY and the remaining path
URL="${BASE_URL}/rest/servicedesk/1/${project_key}/settings/feedback/enable"
# Execute the DELETE request
response=$(curl -s -o /dev/null -w "%{http_code}" -X PUT "$URL" \
-H "Content-type: application/json" \
-H "Accept: application/json" \
-d '{ "enabled": true }' \
-u "$USERNAME:$PASSWORD")
# Check the response code
if [ "$response" -eq 200 ]; then
echo "Successfully enabled feedback for project key: $project_key"
else
echo "Failed to enable feedback for project key: $project_key. Response code: $response"
fi
done < "$FILE_NAME"
Please note that in both these scripts, the project keys are read from a filename: jsm_projects_list.csv that contains the list of the project keys in your Jira instance. And above scripts iterates over these projects.