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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

"Specify a valid project ID or key" exception while creating an issue from Google Script

Edited
I'm trying to create an issue in my Jira (Cloud) project with URL Fetch in Google Script.
The main code is:

    issue = {
        "fields": {
          "issuetype": "Task",
          "summary": "Summary",
          "reporter": {"displayName": "John"},
          "priority": "Medium",
          "project": {"key": projectKey}
        }
      };
    UrlFetchApp.fetch(jiraUrl, {
      method: "POST",
      headers: {
        'Content-Type': "application/json",
        "Authorization": "Basic " + Utilities.base64Encode(userName + ':' + apiToken)
      },
      payload: JSON.stringify(issue)
    });

When I run it, I get a 400 exception: Truncated server response: {"errorMessages":[],"errors":{"project":"Specify a valid project ID or key"}}
However, I'm pretty sure that I put the correct key (shows in the issue datas I got from my Jira project in the same URL Fetch way) of my project into the line ("project": {"key": projectKey})
And I also tried using "project": {"id": projectId}, but still the same exception.
I have found similar questions and reports about this exception on the Internet. But it seems no effective solution mentioned ever.

1 answer

Hi @Zet , welcome to the Atlassian Community!
I have ran into a similar issue before. Does the user or system trying to create the issue have the correct permissions? You might need to update the Browse Project permission as well as the Create issue Permission. If the user/system that is using the credentials in the request cannot "see" the project, the error you get is that the project id/name is invalid. Please let me know if this solves it! Have a nice day!

Thanks for reply. How to check if I have the Create issue Permission? May I check it in google script with code?

I (the user) can create issues in Browser in the project. Isn't it enough?

You can update project permissions through project settings by updating the permission scheme. Permission Documentation 

If your user has create issue and browse project permissions you need to use those credentials to make the request (API token) or give permission to the user you are currently using. Let me know if this helps

uhhh... actually I'm not a manager of the project so I can't access the project settings. But I can browse and create issue in the project with the GUI on the project web page.

And I do created an API token for my Jira account (and I tried revoking and recreated a new one).

And I can even get issue datas in my Google Script code with that token, juse can't create issue in it.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events