Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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

Not able to add attachments while creating issue using Rest Api

Hi, I am trying to add attachments while creating the issue using rest/api/3/issue? api.

{    "issueUpdates": [
        {
            "fields": {
                "summary": "string",
                "issuetype": {
                    "name": "Epic"
                },
                "description": {
                    "type": "doc",
                    "version": 1,
                    "content": [
                        {
                            "type": "paragraph",
                            "content": [
                                {
                                    "text": "string",
                                    "type": "text"
                              }
                            ]
                        }
                    ]
                },
                "project": {
                    "key": "SP"
                },
                "attachment": [
                    {
                        "id": "10003",
                        "filename": "Jira.json",
                        "author": {
                            "self": "https://jb-saurabh.atlassian.net/rest/api/3/user?accountId=5c25230db393bf4ce955eb2c",
                            "accountId": "5c25230db393bf4ce955eb2c",
                            "emailAddress": "saurabh.bhandari@jitterbit.com",
                            "avatarUrls": {
                                "48x48": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/5c25230db393bf4ce955eb2c/46526343-ea20-4917-a41c-fcb740972a27/48",
                                "24x24": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/5c25230db393bf4ce955eb2c/46526343-ea20-4917-a41c-fcb740972a27/24",
                                "16x16": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/5c25230db393bf4ce955eb2c/46526343-ea20-4917-a41c-fcb740972a27/16",
                                "32x32": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/5c25230db393bf4ce955eb2c/46526343-ea20-4917-a41c-fcb740972a27/32"
                            },
                            "displayName": "Saurabh Bhandari",
                            "active": true,
                            "timeZone": "Asia/Calcutta",
                            "accountType": "atlassian"
                        },
                        "created": "2021-05-19T12:37:24.332+0530",
                        "size": 155883,
                        "mimeType": "application/json",
                        "content": "https://jb-saurabh.atlassian.net/secure/attachment/10003/Jira.json"
                    }
                ]            }        }    ]
}

 And I am getting the below error :

 

{
    "issues": [],
    "errors": [
        {
            "status": 400,
            "elementErrors": {
                "errorMessages": [],
                "errors": {
                    "attachment": "string expected at index 0"
                }            },
            "failedElementNumber": 0
        }
    ]
  

Can anyone please help me out to find the current payload

Thanks

 

1 answer

0 votes
Warren Community Leader May 19, 2021

Hi @Saurabh Bhandari 

That is correct, you cannot add an attachment at the time of creating an issue. What you need to do is make a note of the issue key when you create it, then run another API call to add the attachment. I give some C# code in my answer to this post which may help you

thanks @Warren for your reply, But I am getting this attachment node when I request for metadata using rest/api/3/issue/createmeta?projectKeys=SP&issuetypeNames=Epic&expand=projects.issuetypes.fields  for creating a issue

In response, I am getting node for attachment as : 

"attachment": {
                            "required": false,
                            "schema": {
                                "type": "array",
                                "items": "attachment",
                                "system": "attachment"
                            },
                            "name": "Attachment",
                            "key": "attachment",
                            "hasDefaultValue": false,
                            "operations": [
                                "set"
                            ]
                        }

 I think this means we can have attachment data in create issue request.

Please correct me I am doing something wrong

@Warren Can you please check the above details. I am stuck in this. 

Thanks in advance.

Suggest an answer

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

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