I’m having trouble using the Jira REST API to create an issue with a component. The API works fine when I don’t include a component, but it fails when I try to add one. Here’s the JSON I’m using:
In my experience with Jira’s API, getting the component right can be tricky. Instead of using a single component entry, you need to use the plural form and nest the value in an array. It also helps to first query your project’s components using the /project/{projectIdOrKey}/components endpoint to retrieve the precise component ID. Once you have the correct ID, update your payload to something like:
"components": [{"id": "10000"}]
Replace “10000” with the actual component ID. This method has consistently worked in my implementations.
I encountered a similar issue when working with the Jira REST API. The problem is likely in how you’re specifying the component. Instead of ‘component’, you should use ‘components’ (plural) and provide it as an array, even if you’re only adding one component. Try modifying your JSON like this:
"components": [
{
"name": "BackEnd"
}
]
This change should resolve the 400 Bad Request error you’re experiencing. Also, double-check that the component name exactly matches what’s in your Jira project. If the issue persists, you might want to verify your API permissions and ensure the component actually exists in the project you’re targeting.