You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
Hi,
I'm trying to create an issue the same way I have been doing.
{
"url": "https://ХХХХХХХ.atlassian.net/rest/api/3/issue",
"headers": [
"Content-Type: application/json",
"Authorization: Basic ХХХХХ"
],
"data": {
"fields": {
"summary": "{{ticket_field__5211}}, {{ticket_field__5318}}",
"issuetype": {
"id": "10001"
},
"project" : {
"id" : "10000"
},
"customfield_10032" : "{{ticket_id}}",
"customfield_10033" : "2",
"customfield_10034" : "{{ticket_field__5318}}",
"customfield_10035" : "{{ticket_field__5212}}",
"customfield_10044": {
"type": "doc",
"version": 1,
"content": [
{
"type": "paragraph",
"content": [
{
"text": "{{ticket_field__16580}}",
"type": "text"
}
]
}
]
}
}
}
}
Here is the response:
{ "errorMessages": [], "errors": { "project": "Specify a valid project ID or key" }}
But the project id in my request is correct.
I've also tried to use the project key instead, the same problem remains.
Thank you
T
Hey T,
Remove the "Data:" from the body of the request. So the first thing in the json body is fields-
{"fields": {"project": {"id": "xxx"},"summary": "xxx","description": "xxx","issuetype":{"id": "xxx"}}}
This worked for me
What else has been changing is that Atlassian has been fiddling with how much information is revealed when probing sites. See: https://community.developer.atlassian.com/t/jql-queries-containing-issuekey-or-issue-will-have-the-error-messages-and-response-code-changed/48242/2
It's likely Atlassian has changed the REST API responses for more than the rest/api/3/search endpoint to avoid disclosing any information about sites. This might be why you've encountered this now, and why there aren't any good search results for this error message, when a month ago you might've received a much more descriptive error message.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Double-check and triple-check your site URL here. I was having this issue but then I'd noticed I'd copied the REST API endpoint from the docs which is in the form:
https://your-domain.atlassian.net/rest/api/3/issue
For some reason, requests to this endpoint don't reject with 401 unauthorised and instead give
"project": "Specify a valid project ID or key"
Once I'd changed the URL to my actual Atlassian cloud site, it worked fine.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I've checked - the URL is ok.
But still the error remains ("project": "Specify a valid project ID or key")
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I dunno what to say. Like others have said, if this account has permission to create these issues with this issuetype in this project, and you are definitely talking to the right cloud site, there's not much more I can suggest.
The most basic JSON payload is:
This works for me:
curl -u '<username>:<password>' -X POST -H 'Content-Type: application/json' -d '{"fields":{"project":{"id":"13139"},"issuetype": {"id":"10002"},"summary": "REST API created issue"}}' https://<actual-site>.atlassian.net/rest/api/3/issue
In general I'm going to assume well-formed JSON and to keep it simple, you aren't using any arrays. Let's examine the possible error cases for above, These all give error 400, and in rough order:
Hope that helps.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Code wise this looks fine (it also validated to proper JSON).
Are you sure the user that you are authenticating with has the proper permissions for that project? (browser project)
Errors with the REST api can sometimes be obscure, it might tell you you have a wrong ID because it cannot validate the ID. (if you don't have access)
If you try it with another project, does that work?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for your answer, Dirk
I'm authenticating with the admin user.
I've tried it with another project - unfortunately there is the same problem.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Just to be sure, have you also tried that user thru the webinterface?
Being an admin doesn't by default mean that you have permissions on a project.
You can also try the permission helper to be sure
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I've just checked the permissions with the permission helper, so they are okay :(
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Are you able to do any other actions on the project like reading an issue?
Also could you explain how you got to the projectid? (just making sure you got the right one) Using the createmeta endpoint is always helpfull
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, I am
I created an issue (not with api), then used GET /rest/api/3/issue/{issueIdOrKey} and got the project id (10000).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.