Use Rest API Set Action/Comment Error
Use python Set Comment
response Error : Failed to add comment. Error: b''
thank you for your help
import requests
build_id = "867"
comment = "test"
url = f"http://localhost:8111/app/rest/builds/id:{build_id}/comment"
headers = {
"Content-Type": "text/plain",
"Authorization": "Bearer <key>"
}
data = comment.encode("utf-8")
response = requests.put(url, headers=headers, data=data)
if response.status_code == 200:
print("Comment added successfully.")
else:
print(f"Failed to add comment. Error: {response.content}")
Please sign in to leave a comment.
Hello!
The endpoint will return 204 (No Content) in case of a successful response. Instead of checking if status_code property value equals 200, you may consider using response.ok boolean value instead.
Please let me know if this helps.
yes, you are right! Is successfull,thank you