Hey all,
I am trying to update labels via the requests module in python. When I make a get request for the label, I get the desired data, but when I try a post request, I get a 500 error, with the error message
"message":"javax.ws.rs.WebApplicationException: null"}
I'm not entirely sure why this is the case, but it should work. Anyone have any ideas on troubleshooting? My code is below:
def get_labels(id):
full_url = f"{BASE_URL}/{id}/label"
r = requests.get(full_url,
auth=(un, pw))
return r.json()
def format_label(labels):
final = []
for label in labels:
clean_dict = {
"prefix": "global",
"name": label
}
final.append(clean_dict)
return json.dumps(final)
def _update_label(id, labels):
data = format_label(labels)
full_url = f"{BASE_URL}/{id}/label"
r = requests.post(
full_url,
auth=(un, pw),
data=data,
headers=({"Content-Type": "appliction/json"})
)
print(r.text)
def main():
_update_label(id, labels)
main()