Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

API Create Issue and set object id at the same time

Luke Gibson
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!
October 24, 2024

Hi, 

 

I have been trying to create an issue and set object fields on creation. 

When I do this it will say :

'{"errorMessages":[],"errors":{"customfield_12345":"Field \'customfield_12345\' cannot be set. It is not on the appropriate screen, or unknown."}}'

However if I create the issue first then update the issue it will set the object field. Surely you can set object fields on creation?

 

 

 

url = f"{companydomain}/rest/api/2/issue/"
   
 
payload = json.dumps(
   
{
    "fields": {

        "summary":summary,
        "project":{"key":project_key},
        "issuetype":{"id":issueType},
         'customfield_12345': [
             {'objectId': '123456}
             ],

        },
   
   
})

response_create = requests.request(
    "POST",
    url,
    data=payload,
    headers=headers,
    auth=auth
    )

1 answer

1 accepted

3 votes
Answer accepted
Salih Tuç
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.
October 24, 2024

Hi @Luke Gibson , welcome to the Community!

You need to check your Jira project's screens. Rest API expects that the field is visible on screens when you call it.

In other words,

  • When you are setting a value for a field while creating the issue, the field should be on "Create Issue" screen.
  • When you need to set a value after issue created, the field should be on "Edit Issue" screen.

Can you please check that your custom field is on create screen or not?

Luke Gibson
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!
October 24, 2024

Ah I see, this makes sense. Thank you. 

Like Salih Tuç likes this

Suggest an answer

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

Atlassian Community Events