Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

"Specify a valid project ID or key" / creating issue Edited

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

4 answers

1 vote
TJ Young I'm New Here Jun 23, 2021

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

0 votes
Dirk Ronsmans Community Leader Jun 22, 2021

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?

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.

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

I've just checked the permissions with the permission helper, so they are okay :(

TJ Young I'm New Here Jun 22, 2021

I am also having this same exact issue.

Dirk Ronsmans Community Leader Jun 23, 2021

@Тимур Балиашвили ,

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

https://developer.atlassian.com/server/jira/platform/jira-rest-api-example-discovering-meta-data-for-creating-issues-6291669/

Yes, I am

I created an issue (not with api), then used GET /rest/api/3/issue/{issueIdOrKey} and got the project id (10000).

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.

I've checked - the URL is ok.

But still the error remains ("project": "Specify a valid project ID or key")

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:

  • {"fields":{"project":{"id":"13139"},"issuetype": {"id":"10002"},"summary": "REST API created issue"}}

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:

  • {"errorMessages":["No content to map to Object due to end of input"]}
    • I don't send a payload.
  • "errors":{"project":"Specify a valid project ID or key"}
    1. I send the request to your-domain.atlassian.net
    2. I misspell "fields", or "project", or "id" in the JSON
    3. I leave out "id"/"key", "project" or "fields".
    4. I send an empty object, ie. {} is the payload
    5. I send project as an object array instead of as a single object
    6. I send an anonymous request with an invalid project ID
  • "errors":{"issuetype":"Specify an issue type"}
    • I misspell issuetype or id, or I leave it out
  • "errors":{"issuetype":"Specify a valid issue type"}
    • I set an invalid issue type
    • I send an anonymous request with an invalid issue type
  • "errors":{"summary":"You must specify a summary of the issue."}
    • I send an empty string, or I misspell summary, or I leave it out
  • "errors":{"project":"Anonymous users do not have permission to create issues in this project. Please try logging in first."}}
    • I send an anonymous request but I don't send a summary
  • "errors":{"summary":"Operation value must be a string"}
    • I send an array of strings
  • "errors":{"summary":"Field 'summary' cannot be set. It is not on the appropriate screen, or unknown."}
    • I don't have the "Create Issue" permission
    • I send an anonymous request with a valid project ID, issue type ID, and summary.

Hope that helps.

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.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira Service Management

Atlympic Event: Jira Service Managemnt

Hello Community!  Quick disclaimer: We are running a contest on Community (The Atlympics!) from July 23rd - August 8th of 2021. If you are interested in participating in this contest (prizes! ...

87 views 0 1
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you