TL;DR Script for updating PeopleGoal Feedback Questions per User
Discovered PeopleGoal recently.
I like codifying peoples' job responsibilities via the Feedback Question but for 33 reports in my org, neither I nor my managers can be bothered to key-in each via the UI.
Am told by PeopleGoal customer support their public API might be available later in 2019.
The workaround: figure out how to update via CLI.
- got working with Postman
- copy-pasted Python code
- created
responsiblities.txt
locally - added looping to go through users and add responsbilities programmatically
$ SESSION=<SESSION_ID_FROM_COOKIES> python peoplegoal_updater.py <USER_ID> <QUESTION_ID>
# YMMV; provided as-is, no warranty
import sys
import urllib
import requests
import os
user_id = sys.argv[1]
starting_question_id = sys.argv[2]
next_question_id = int(starting_question_id) + 1
session=os.environ['SESSION']
print "***************"
lines = tuple(open("responsibilites.txt", 'r'))
for line in lines:
responsibility = line.rstrip()
url = "https://decorist.peoplegoal.com/feedback_questions/" + user_id + "/new_user_feedback_question"
headers = {
'Cookie': "_peoplegoal_v2_session_store=" + session + ";"
}
# Creates a new question, but doesn't return ID of question
print "Question ID: " + str(next_question_id)
response = requests.request("GET", url, headers=headers)
print "HTTP Code (New Question): " + str(response.status_code)
url = "https://decorist.peoplegoal.com/feedback_questions/" + str(next_question_id)
payload = "{\"feedback_question\": { \"question_text\": \"" + responsibility + "\"} }"
headers = {
'Cookie': "_peoplegoal_v2_session_store=" + session + ";",
'Content-Type': "application/json"
}
# Update the question
response = requests.request("PUT", url, data=payload, headers=headers)
print "Responsiblity: '" + responsibility + "'"
print "HTTP Code (Question Updated): " + str(response.status_code)
next_question_id += 1
print "***************"
$ SESSION=<SESSION_ID_FROM_COOKIES> python cleanup.py <QUESTION_ID>
# YMMV; provided as-is, no warranty
import sys
import requests
import os
question_id = sys.argv[1]
session=os.environ['SESSION']
url = "https://decorist.peoplegoal.com/feedback_questions/" + question_id
payload = "_method=delete"
headers = {
'Cookie': "_peoplegoal_v2_session_store=" + session + ";",
'Content-Type': "application/x-www-form-urlencoded"
}
response = requests.request("POST", url, data=payload, headers=headers)
print response.status_code # getting 500 but question is deleted...