I’m hitting a snag while trying to make a JIRA ticket using their REST API. I’ve set up a curl command to send a POST request, but it’s not going through. Here’s what I’m working with:
When I run this, I get a 400 Bad Request error. The response mentions something about an unrecognized token and expecting ‘null’, ‘true’, ‘false’ or NaN.
I’m scratching my head over this one. Any ideas what might be going wrong? Thanks in advance for any help!
hey mate, i had a similar issue. check ur JSON for hidden characters or extra spaces. sometimes they sneak in. also, make sure ur project key is correct. MYPROJ might not exist. try running the curl command with -v for more debug info. that usually helps pinpoint the problem. good luck!
I’ve dealt with similar JIRA API issues before, and it sounds like there might be a problem with your JSON formatting. One thing to check is if you have any hidden characters or line breaks in your JSON file. Sometimes text editors can add these invisibly. Try using a JSON validator to ensure your file is properly formatted. Also, you could try escaping the quotes in your JSON or using single quotes for the curl command and double quotes in the JSON. Another possibility is that your JIRA instance might require additional fields that aren’t in your JSON. Check your project’s required fields and make sure they’re all included. Lastly, double-check your JIRA permissions. Even if your credentials are correct, you might not have the right permissions to create issues via the API. If none of these solve it, try enabling verbose output in curl (-v flag) to get more detailed error information. That often helps pinpoint the exact issue.
From my experience, JIRA API can be finicky about the Content-Type header. Try explicitly setting it to ‘application/json’ in your curl command. Also, ensure your JIRA instance is compatible with the API version you’re using (/rest/api/2/). Some older JIRA versions might require a different endpoint.
Another potential issue could be with the ‘issuetype’ field. Some JIRA configurations use IDs instead of names for issue types. You might need to replace “name”: “Task” with “id”: “10002” (or whatever the correct ID is for your JIRA setup).
Lastly, if you’re using Windows, watch out for line ending differences. Unix-style LF might be required instead of Windows CRLF. A quick fix is to use a text editor that supports different line endings and save the file with LF.