"project": "project is required"

Veeranjaneyulu Kureti August 22, 2020

This is the error I am getting when I am trying to create a project.

"errorMessages": [],
"errors": {
"project": "project is required"
}

 

 

code That I have used.

 

# This code sample uses the 'requests' library:http://docs.python-requests.orgimport requestsfrom requests.auth import HTTPBasicAuthimport json
url = "https://rasateam.atlassian.net/rest/api/3/issue/"
auth = HTTPBasicAuth("<MYUSERID>""<APITOKEN>")
headers = {   "Accept""application/json",   "Content-Type""application/json"}
payload = json.dumps( {  "update": {},  "fields": {    "summary""Creating first ticket from API"    #"parent": {     # "key": "RASA"    },    "issuetype": {      "id""10000"    },    "components": [      {        "id""10000"      }    ],    #"customfield_20000": None,    #"customfield_40000": None,    #"customfield_70000": None,    "project": {      "id""10000",      "key""RASA",      "name""RASASLACKBOT",      "projectTypeKey""software",      "self""https://rasateam.atlassian.net/rest/api/3/project/10000",      #"simplified": false    },    "description"None,    "reporter": {      "id""5f362439fdc3f5003f7fd882"    },    "fixVersions": [],    #"customfield_10000":  "{}",    "priority": {      "id""3"    },    "labels": [      "bugfix",      "blitz_test"    ],    #"timetracking": {     # "remainingEstimate": "5",      #"originalEstimate": "10"    #},    #"customfield_30000": None,    #"customfield_80000": None,    #"security": None,    #"environment": {     # "type": "doc",      #"version": 1,      #"content": [       # {        #  "type": "paragraph",         # "content": [          #  {           #   "text": "UAT",            #  "type": "text"            #}          #]        #}      #]    #},    #"versions": [      #{        #"id": "10000"     # }   # ],    #"duedate": "2019-05-11",    #"customfield_60000": "jira-software-users",    #"customfield_50000": {     # "type": "doc",      #"version": 1,      #"content": [       # {        #  "type": "paragraph",         # "content": [          #  {           #   "text": "Could impact day-to-day work.",            #  "type": "text"            #}          #]        #}      #]    #},    "assignee": {      "id""5b109f2e9729b51b54dc274d"    } } )
response = requests.request(   "POST",   url,   data=payload,   headers=headers,   auth=auth)
print(json.dumps(json.loads(response.text), sort_keys=Trueindent=4separators=(","": ")))

2 answers

0 votes
Anjani Doolla
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 23, 2024

Hi @Prince Nyeche I am also getting 400 bad request Project is required error while trying to create issue from postman  

Could you please help me to resolve this issue, attaching here payload and error screenshot:

JiraIssue.PNG

Payload : 

{
    "update": {
        "worklog": [
            {
                "add": {
                    "timeSpent": "60m",
                    "started": "2024-05-23T11:05:00.000+0000"
                }
            }
        ]
    },
    "fields": {
        "summary": "Creating first ticket from API ",
        "project": {
            "id": "OCTSAP"
        },
        "summary": "something's wrong",
        "issuetype": {
            "id": "10000"
        },
        "assignee": {
            "name": "anjani"
        },
        "reporter": {
            "name": "aravind"
        },
        "priority": {
            "id": "High"
        },
        "labels": [
            "bugfix",
            "blitz_test"
        ],
        "timetracking": {
            "originalEstimate": "10",
            "remainingEstimate": "5"
        },
        "security": {
            "id": ""
        },
        "versions": [
            {
                "id": ""
            }
        ],
        "environment": "DEV",
        "description": "description",
        "duedate": "2024-05-25",
        "fixVersions": [
            {
                "id": ""
            }
        ],
        "customfield_20000": "23/May/24 3:25 PM",
        "customfield_40000": "this is a text field",
        "customfield_70000": [
            "jira-administrators",
            "jira-software-users"
        ],
        "customfield_60000": "jira-software-users",
        "customfield_50000": "this is a text area. big text.",
        "customfield_10000": "23/May/24"
    }
}
0 votes
Prince Nyeche
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 23, 2020

Hi @Veeranjaneyulu Kureti 

I don't think you're connecting to the Project API hence such error. you should use in the url variable.

 https://rasateam.atlassian.net/rest/api/3/project

Then specify the fields you want available during creation in your json payload. A Python example is shown on the developers doc here

Veeranjaneyulu Kureti August 23, 2020

Hi @Prince Nyeche 

Thanks for your response. 

I wanted to create an issue in the Project, Here where I am facing the issue.

So as per your suggestion first you want me to connect to the project and there you wanted me to create an issue ? 

As I am able to retrieve the Project and Issue details but unable to create a project.

Can you please elaborate a bit how we can create an issue in the required project.

Thanks in advance !! 

Prince Nyeche
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 23, 2020

Hey @Veeranjaneyulu Kureti 

If you simply want to create an issue, use the create issue API to do that, in your request payload that's where you specify the project to connect to. Creating Issues or Projects are separate APIs, so if you want to do either use the designated API to achieve your aim.

Like Veeranjaneyulu Kureti likes this
Veeranjaneyulu Kureti August 23, 2020

Thanks Prince.

The API code which mentioned above and causing the error is for the Create issue API.

If you can please have a look into my code and check which required details I am missing in the mentioned python code Because it is causing this error.

"errorMessages": [],
"errors": {
"project": "project is required"

 

Python code : 

# This code sample uses the 'requests' library:# http://docs.python-requests.orgimport requestsfrom requests.auth import HTTPBasicAuthimport json
url = "https://rasateam.atlassian.net/rest/api/3/issue/"
auth = HTTPBasicAuth("<MYUSERID>", "<APITOKEN>")
headers = {   "Accept": "application/json",   "Content-Type": "application/json"}
payload = json.dumps( {  "update": {},  "fields": {    "summary": "Creating first ticket from API"    #"parent": {     # "key": "RASA"    },    "issuetype": {      "id": "10000"    },    "components": [      {        "id": "10000"      }    ],    #"customfield_20000": None,    #"customfield_40000": None,    #"customfield_70000": None,    "project": {      "id": "10000",      "key": "RASA",      "name": "RASASLACKBOT",      "projectTypeKey": "software",      "self": "https://rasateam.atlassian.net/rest/api/3/project/10000",      #"simplified": false    },    "description": None,    "reporter": {      "id": "5f362439fdc3f5003f7fd882"    },    "fixVersions": [],    #"customfield_10000":  "{}",    "priority": {      "id": "3"    },    "labels": [      "bugfix",      "blitz_test"    ],    #"timetracking": {     # "remainingEstimate": "5",      #"originalEstimate": "10"    #},    #"customfield_30000": None,    #"customfield_80000": None,    #"security": None,    #"environment": {     # "type": "doc",      #"version": 1,      #"content": [       # {        #  "type": "paragraph",         # "content": [          #  {           #   "text": "UAT",            #  "type": "text"            #}          #]        #}      #]    #},    #"versions": [      #{        #"id": "10000"     # }   # ],    #"duedate": "2019-05-11",    #"customfield_60000": "jira-software-users",    #"customfield_50000": {     # "type": "doc",      #"version": 1,      #"content": [       # {        #  "type": "paragraph",         # "content": [          #  {           #   "text": "Could impact day-to-day work.",            #  "type": "text"            #}          #]        #}      #]    #},    "assignee": {      "id": "5b109f2e9729b51b54dc274d"    } } )
response = requests.request(   "POST",   url,   data=payload,   headers=headers,   auth=auth)
print(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")))

I have provided my credentials for this.

<MYUSERID> 

<APITOKEN>

 

Please help me with which details I am missing in it.

Prince Nyeche
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 23, 2020

Do you have a Project with id:10000 on your Instance? you might want to check the Id of the project you're trying to create this issue on.

Veeranjaneyulu Kureti August 24, 2020

 

@Prince NyecheYes Prince, It is the project Id : 10000 on my instance. and when I am trying to get to details I am able to get details of issue and project but unable to create project or Issue.

 

Please help me that might I am missing any fields or anything as I set the "customfield_N0000": None custom filed none and Initially it thrown that I am not suppose to set that ..can you please suggest me how what are all the fields required for creating the issue. Will take that as reference and check with my case. Thanks!! Please check the above code and let me know . Thanks in advance!!

Prince Nyeche
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 25, 2020

Hi @Veeranjaneyulu Kureti 

So  I examined the json and it seems that the way you nested it was wrong. all those other fields should be nested inside of the "field": {  }  element. That's why that error was occuring. I cleaned the code up a bit for you. Please give it a try.

import requests
import json
from requests.auth import HTTPBasicAuth


def main():
url = "https://<yourinstance>.atlassian.net/rest/api/3/issue/"
auth = HTTPBasicAuth("<emailaddress>", "<apitoken>")
headers = {"Content-Type": "application/json"}

payload = {
"update": {

},
"fields": {
"summary": "Creating first ticket from API ",
"project": {
"id": "10016"
},

"issuetype": {
"id": "10004"
},
"description": None,
"reporter": {
"id": "5d2c28bd9dshdsddf9f"
},
"fixVersions": [

],
"priority": {
"id": "3"
},
"labels": [
"bugfix",
"blitz_test"
],
"assignee": {
"id": "5ab519dshdshdshdbb2b2"
}
}
}

response = requests.post(url, auth=auth, json=payload, headers=headers)
data = json.loads(response.content)
print(data)


if __name__ == "__main__":
main()
Slack Jira
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 27, 2020

Yes @Prince Nyeche Its working fine now Thank you so much!!

Veeranjaneyulu Kureti August 28, 2020

Hi @Prince Nyeche  Its working fine now Thank you so much!!

 

But Here I can able to create and delete the Issues and get details about the issue in a project. But I am facing issue with creating a project and editing the issue through API.

 

Can you please suggest codes for that as well ?? If you don't mine sorry for bothering you much!! 

Prince Nyeche
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 31, 2020

Hey @Veeranjaneyulu Kureti  Are you using some form of SDK or Library to do this, or you're simply calling different script at a time. Can you post the sample code you're using so far for project creation and editing the issue and any errors you've gotten so far?

Veeranjaneyulu Kureti September 2, 2020

Hi @Prince Nyeche Thanks for your reply.

 

Issue with commenting in the JIRA ISSUE :

 

Error :

PS C:\Users\VeeranjaneyuluKureti\RASA_VEERU> python Comment_JIRA.py
{
"errorMessages": [],
"errors": {
"commentLevel": "You are currently not a member of the project role: Administrators."
}
}

 

 

code :

import requestsfrom requests.auth import HTTPBasicAuthimport json
url = "https://ID.atlassian.net/rest/api/3/issue/SLAC-4/comment"
auth = HTTPBasicAuth(ID, TOKEN)
headers = {   "Accept""application/json",   "Content-Type""application/json"}
payload = json.dumps( {  "visibility": {    "type""role",    "value""Administrators"  },  "body": {    "type""doc",    "version"1,    "content": [      {        "type""paragraph",        "content": [          {            "text""Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque eget venenatis elit. Duis eu justo eget augue iaculis fermentum. Sed semper quam laoreet nisi egestas at posuere augue semper.",            "type""text"          }        ]      }    ]  }} )
response = requests.request(   "POST",   url,   data=payload,   headers=headers,   auth=auth)
print(json.dumps(json.loads(response.text), sort_keys=Trueindent=4separators=(","": ")))

 

Issue : EDITING ISSUE 

ERROR : 

PS C:\Users\VeeranjaneyuluKureti\RASA_VEERU> python Edit_issue.py
Traceback (most recent call last):
File "Edit_issue.py", line 76, in <module>
main()
File "Edit_issue.py", line 70, in main
response = requests.post("PUT",url, auth=auth, json=payload, headers=headers)
File "C:\Users\VeeranjaneyuluKureti\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\api.py", line 119, in post
return request('post', url, data=data, json=json, **kwargs)
File "C:\Users\VeeranjaneyuluKureti\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Users\VeeranjaneyuluKureti\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\sessions.py", line 516, in request
prep = self.prepare_request(req)
File "C:\Users\VeeranjaneyuluKureti\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\sessions.py", line 459, in prepare_request
hooks=merge_hooks(request.hooks, self.hooks),
File "C:\Users\VeeranjaneyuluKureti\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\models.py", line 314, in prepare
self.prepare_url(url, params)
File "C:\Users\VeeranjaneyuluKureti\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\models.py", line 388, in prepare_url
raise MissingSchema(error)
requests.exceptions.MissingSchema: Invalid URL 'PUT': No schema supplied. Perhaps you meant http://PUT?
PS C:\Users\VeeranjaneyuluKureti\RASA_VEERU>

CODE :

import requestsimport jsonfrom requests.auth import HTTPBasicAuth

def main():    url = "https://ID.atlassian.net/rest/api/3/issue/"    auth = HTTPBasicAuth("ID", "TOKEN")    headers = {"Content-Type": "application/json"}
    payload = {        "update": {            "summary": [              {                "set": "Bug in business logic"              }             ],            "components": [              {                "set": ""              }            ],            "timetracking": [              {                "edit": {                  "remainingEstimate": "4d",                  "originalEstimate": "1w 1d"                }              }            ],            "labels": [              {                "add": "triaged"              },              {                "remove": "blocker"              }            ]
        },        "fields": {            "summary": "Creating second ticket from API  ",            "project": {                "id": "10000"            },
            "issuetype": {                "id": "10001"            },            "description": None,            "reporter": {                "id": "5f4786a7347294003e78e33d"            },            "fixVersions": [
            ],            "priority": {                "id": "3"            },            "labels": [                "bugfix",                "blitz_test"            ],             "assignee": {                "id": "5f362439fdc3f5003f7fd882"            }        }    }
    response = requests.post("PUT",url, auth=auth, json=payload, headers=headers)    data = json.loads(response.content)    print(data)

if __name__ == "__main__":    main()

 

ISSUE : CREATING A PROJECT.

ERROR : 

PS C:\Users\VeeranjaneyuluKureti\RASA_VEERU> python creating_project.py
{
"errorMessages": [
"Can not deserialize instance of java.lang.String out of START_OBJECT token\n at [Source: org.apache.catalina.connector.CoyoteInputStream@7406b7a0; line: 1, column: 46] (through reference chain: com.atlassian.jira.rest.v2.issue.project.ProjectInputBean[\"lead\"])"
]
}
PS C:\Users\VeeranjaneyuluKureti\RASA_VEERU>

CODE :

import requestsfrom requests.auth import HTTPBasicAuthimport json
url = "https://ID.atlassian.net/rest/api/3/project"
auth = HTTPBasicAuth("ID", "TOKEN")
headers = {   "Accept": "application/json",   "Content-Type": "application/json"}
payload = json.dumps( {  #"notificationScheme": 10021,  "description": "Example Project description",  "lead": {        "Id": "5f4786a7347294003e78e33d"          },  #"url": "https://slackjira2020.atlassian.net/PROJAPI",  "projectTemplateKey": "com.pyxis.greenhopper.jira:gh-simplified-agility-scrum",  #"avatarId": 10318,  #"issueSecurityScheme": 10001,  "name": "PROJECT_API",  #"permissionScheme": 10011,  "assigneeType": "PROJECT_LEAD",  "projectTypeKey": "software",  "key": "PROJAPI",  #"categoryId": 10120} )
response = requests.request(   "POST",   url,   data=payload,   headers=headers,   auth=auth)
print(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")))

 

Please help me out of this three codes which I am facing an issue. Thanks in advance!! 

Prince Nyeche
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 4, 2020

Hey @Veeranjaneyulu Kureti 

Basically, i looked at the json and it seems that you're not properly formatting it and using wrong methods in the request. There are 3 things you need to be aware of here

  1. PUT request  in the context of Edit issue does not return  a json response, so you can use a status_code to check if it was successful or not.
  2. Check your permissions for comment issue to ensure you have the right ones in terms of setting comment visibility, ensure you're in the right role.
  3. Project creation use leadaccountId, i believe the example in the Doc is wrong, so you might want to take note of this.

Just wanted to give you a baseline of how you could go about this, since you will be calling "GET", "PUT", "POST". it's better to have a method for this and pass the url and payload at will. I created this script to show you an example of how it would look.

Furthermore, for Edit issue, you should take a look at the fields from this endpoint /rest/api/3/field grab the field id if you want to PUT to a custom field. I wrote the example of some common field with how their payload should look like.

import requests
import json
from requests.auth import HTTPBasicAuth

EMAIL = "<email>"
TOKEN = "<apitoken>"
URL = "https://<your-instance>.atlassian.net/rest/api/3/myself"


class Jira:
def __init__(self):
self.url = URL
self.auth = HTTPBasicAuth(EMAIL, TOKEN)
self.headers = {"Content-Type": "application/json"}

def __str__(self):
self.login = self.get_only()
self.accept = "Login Accepted..."
self.reject = "Login Failed..."
if self.login.status_code == 200:
return self.accept
else:
return self.reject

def get_only(self):
response = requests.get(self.url, auth=self.auth, headers=self.headers)

return response

def get_payload(self, url, payload):
response = requests.get(url, auth=self.auth, json=payload, headers=self.headers)
data = json.loads(response.content)

return data

def post_payload(self, url, payload):
response = requests.post(url, auth=self.auth, json=payload, headers=self.headers)
data = json.loads(response.content)

return data

def put_payload(self, url, payload):
response = requests.put(url, auth=self.auth, json=payload, headers=self.headers)
if response.status_code == 204:
success = "Data has been Posted..."
return success
else:
fail = "Failure Posting Data..."
return fail


def main():
issue = Jira()
# print out if api connection is successful or not
print(issue)

# define new urls and payload in main() and call the request by using
# the method in Jira Class

# issue comment example
url = "https://<your-instance>.atlassian.net/rest/api/3/issue/AT2-466/comment"
payload = (
{
"visibility": {
"type": "role",
"value": "Administrators"
},
"body": {
"type": "doc",
"version": 1,
"content": [
{
"type": "paragraph",
"content": [
{
"text": "Test restoreLorem ipsum dolor sit amet, consectetur adipiscing elit. "
"Pellentesque eget venenatis elit. "
"Duis eu justo eget augue iaculis fermentum. Sed semper quam "
"laoreet nisi egestas at "
"posuere augue semper.",
"type": "text"
}
]
}
]
}
}
)
issue.comment = issue.post_payload(url, payload)

# print(issue.comment)

# create a project example
url = "https://<your-instance>.atlassian.net/rest/api/3/project"

payload = (
{
"notificationScheme": 10000,
"description": "Community API Creation",
"leadAccountId": "5ab5195e0dcb662ab2b2",
"url": "https://atlassian.com",
"projectTemplateKey": "com.pyxis.greenhopper.jira:gh-simplified-scrum-classic",
"avatarId": 10401,
"issueSecurityScheme": 10001,
"name": "Community API Creation Project",
"permissionScheme": 10000,
"assigneeType": "PROJECT_LEAD",
"projectTypeKey": "software",
"key": "CACP",
"categoryId": 10000
}
)

issue.project = issue.post_payload(url, payload=payload)

# print(issue.project)

# edit issue example
url = "https://<your-instance>.atlassian.net/rest/api/3/issue/AT2-364"

payload = \
{
# to see the field id goto /rest/api/3/field
# custom fields needs to use their custom id prior to put or post
"fields":
{
# custom field type single options value
"customfield_10087":
{
"value": "UK",
},
# String value - custom field type Text Field
"customfield_10095": "RH011",

# user value - custom field type Single User picker
"customfield_10120":
{
"accountId": "557058:5bced99d8bd8d"
},
"priority": {
"id": "3"
},

# system fields labels - placed in a list
"labels": [
"space",
"red"
],
}
}

issue.edit = issue.put_payload(url, payload)

print(issue.edit)


if __name__ == "__main__":
main()

Hope you can use this examples for your other type of request; as what you can do is just define the url and payload properly and the script can basically get the response.

Veeranjaneyulu Kureti September 6, 2020

Thank you so much!! @Prince Nyeche This helps me a lot!! 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events