I am trying to use bulk api edit endpoint to add comment. Here is my code:
import requests
from requests.auth import HTTPBasicAuth
import json
url = f"{DOMAIN}/rest/api/3/bulk/issues/fields"
auth = HTTPBasicAuth(USERNAME, API_TOKEN)
headers = {
"Accept": "application/json",
"Content-Type": "application/json"
}
# Update this payload to include a valid ADF object for the comment
payload = json.dumps({
"editedFieldsInput": {
"richTextFields": [
{
"fieldId": "comment",
"richText": {
"version": 1,
"type": "doc",
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "Hello "
},
{
"type": "text",
"text": "world",
"marks": [
{
"type": "strong"
}
]
}
]
}
]
}
}
]
},
"selectedIssueIdsOrKeys": [
"TLP-141103" # Add your issue key here
],
"selectedActions": [
"comment"
],
"sendBulkNotification": True # This will send a notification
})
response = requests.post(
url,
data=payload,
headers=headers,
auth=auth,
verify=False
)
# Check for success or errors
if response.status_code == 201:
print("Issues updated successfully!")
else:
print(f"Error: {response.status_code} - {response.text}")
I am able to do fixversion and priority using the same endpoint, the issue above seems to be with richText and i used the same code provided here
https://developer.atlassian.com/cloud/jira/platform/apis/document/structure/ . The error i get is
Error: 400 - {"errorMessages":["Invalid request payload. Refer to the REST API documentation and try again."]} which is very generic.
Here is a working version of fix version and priority if anyone needs it:
Any help is appreciated.
import requests
from requests.auth import HTTPBasicAuth
import json
# Replace with your Jira domain, project key, email, and API token
url = f"{DOMAIN}/rest/api/3/bulk/issues/fields"
auth = HTTPBasicAuth(USERNAME, API_TOKEN)
headers = {
"Accept": "application/json",
"Content-Type": "application/json"
}
# Update this payload to your requirements
payload = json.dumps({
"editedFieldsInput": {
"multipleVersionPickerFields": [
{
"bulkEditMultiSelectFieldOption": "ADD", # Add the version
"fieldId": "fixVersions", # This is the field for Fix Versions
"versions": [
{
"versionId": "14594" # The ID of the Fix Version you're adding
}
]
}
],
"priority": {
"priorityId": "5"
},
},
"selectedIssueIdsOrKeys": [
"TLP-141103" # Add your issue key here
],
"selectedActions": [
"fixVersions",
"priority"
],
"sendBulkNotification": True # This will send a notification
})
response = requests.post(
url,
data=payload,
headers=headers,
auth=auth,
verify=False
)
# Check for success or errors
if response.status_code == 201:
print("Issues updated successfully!")
else:
print(f"Error: {response.status_code} - {response.text}")