Hey there, SurfingWave! I’ve been down this road before with Jira API, and it can be a real pain. Here’s what worked for me:
First, double-check your Jira connection. Sometimes the issue isn’t in the code, but in how you’re connecting to Jira. Make sure your API token or credentials are up to date.
Next, try simplifying your ticket_data structure. Jira can be picky about field names. For custom fields like ‘Epic’ and ‘Sprint’, you might need to use their custom field IDs instead. Something like ‘customfield_10001’ for Epic, for example.
Also, have you verified that ‘coolDev’ is a valid assignee in your Jira instance? If not, that could throw things off.
Lastly, try printing out your ticket_data before sending it to Jira. Sometimes seeing the exact structure can reveal issues that aren’t obvious in the code.
Hope this helps! Let us know if you figure it out.
the double asterisks unpack the dict. also, check if ‘Epic’ and ‘Sprint’ are custom fields in ur jira. if they are, u might need to use their actual field IDs instead of names. good luck man!
I encountered a similar issue when working with Jira’s API. The problem likely stems from how you’re passing the ticket data to the create_issue method. Instead of using ‘fields=ticket_data’, try passing the entire dictionary directly:
jira_conn.create_issue(ticket_data)
This should resolve the KeyError. Also, ensure your Jira connection (jira_conn) is properly initialized with the correct credentials and API endpoint. If the issue persists, double-check your project key ‘MAIN’ exists and you have the necessary permissions to create issues in that project.
Lastly, consider using a try-except block to catch and print any JSON-related errors, which can provide more detailed information about what’s going wrong during the API call.