Forums

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

interacting with JIRA through its REST API v2,

Mengmeng Yu
Contributor
March 17, 2021

Hi team , I am interacting with JIRA through its REST API v2

and there are some unexpected behaviors compare to official developer document

JIRA software version: 8.8.1

Capture.PNG

Cases:

  • About developer REST API reference:

I found 2 REST API references: Jira Server platform REST API reference(Jira 8.8.1) vs Jira Cloud platform Developer REST API v2 Reference.

Both of these references support the “/rest/api/2”, and I compared these 2 references, some APIs in Jira Server platform REST API reference are missing in the Jira Cloud platform Developer REST API v2 Reference, would you please show me which reference should I follow for this Jira software v8.8.1?

 

  • Unable to set an assignee while creating an Jira issue

According to the example in creating an issue in both references, there is an field “assignee” in the Body Parameters with user’s account id / name. I think the ‘Create Issue’ REST API mentions in both references should support creating an issue with “assignee” which is offered in the request body.

Example in Jira Cloud platform Developer REST API v2 Reference

Capture.PNG

Create issue and provide assignee with accountId

Example in Jira Server platform REST API reference(Jira 8.8.1)

Capture.PNG

Create issue and provide assignee with name

However, I encounter 2 issues in creating an issue with “assignee”:

  • I try to set the assignee with name and key, but after creating issue successfully, the assignee is not as expected (it has been assigned as the basic-auth user who post the request)
  • I try to set it with the accountId, however, no “accountId” in the response: please check this screenshotCapture.PNG
  • Right now when I want to create an issue with “assignee”, I have to call 2 APIs:

    • Create an issue without “assignee” first;
    • Update the “assignee” field on the issue I just created

    This make me worry that, I am not sure whether some other fields would cause the same issue as the field “assignee” does in creating an issue. If yes, then it would be a very bad user experience.

     

    • Unable to retrieve values on custom field according REST API reference

    Again, while I am trying to creating an issue, I would like to retrieve values from my custom field under project which user selected.

    I try the REST API mentions in both references, but the result is not expected, would you please advise me how to retrieve the options/value from my customField?

           Here are the details:

    • In Jira Server platform REST API reference(Jira 8.8.1),

    There isn’t any REST API to list the options by customFieldId, only has an Get custom field option API to get the option with specific option id (GET /rest/api/2/customFieldOption/{id})

    • In Jira Cloud platform Developer REST API v2 Reference, It do provide an REST Get custom field options (context) API to retrieve the options by customFieldId an contextId (GET /rest/api/3/field/{fieldId}/context)

    Unfortunately, it response 404 when I try to lookup contextId by customFieldId.

    Here are the steps:

    Response:

    Get ContextId by customFeildId: https://gbm-bds-jira.systems.uk.hsbc:8443/rest/api/2/field/customfield_10200/context

    Response:

     Capture.PNG

1 answer

0 votes
Tom Lister
Community Champion
March 17, 2021

Hi @Mengmeng Yu 

What issues are you getting?

Mengmeng Yu
Contributor
March 17, 2021

Hi , tom , I just update the detail

Wing S C Chen
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!
March 17, 2021

Hi @Tom Lister 

Let me summarize the issues I got when I'm interacting with REST API v2:
I'm now calling the REST endpoint v2 on Jira-v8.8.1

What developer reference should I follow when calling the REST endpoint v2 on Jira-v8.8.1

I found 2 references: Jira Server platform REST API reference(Jira 8.8.1) and Jira Cloud platform Developer REST API v2 Reference.

Both references support the REST API v2, but there are some differences on the REST API v2 between these 2 references. Which one should I follow when I am interacting with jira-v8.8.1?

Unable to set an assignee while creating an Jira issue

  • In the example of creating issue in both references, it set an "assignee" field in the request body, then I expect I can assign someone when create an issue. however, it doesn't work at all;
  • {Get /rest/api/2/user?key=xxx}'s response does not contain a field "accountId".

Unable to retrieve values on custom field according REST API reference

  • No REST API v2 in Jira Server platform REST API reference(Jira 8.8.1) Reference for me to retrieve the options in a custom_field
  • REST API v2 {GET /rest/api/2/field/{fieldId}/context} in Jira Cloud platform Developer REST API v2 Reference response 404 when I try to lookup a context_Id by the custom_field_id
Wing S C Chen
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!
March 17, 2021

Hi @Tom Lister 

You can check the details posted by @Mengmeng Yu 

Tom Lister
Community Champion
March 18, 2021

Hi @Mengmeng Yu @Wing S C Chen 

Please bear in mind that this is a community not the Atlassian support desk.

Re API reference - the Cloud and Server API's are different so the latest published version for your platform is the one to use.

Server/Data Centre = https://docs.atlassian.com/software/jira/docs/api/REST/8.5.12/

Is the username an existing user?
the response /rest/api/2/user?key=xxx}'s response does not contain a field "accountId". suggest it does not
double check the name value.
Does it work if you create an issue manually?
Does your user have 'Assignable User' permissions in the project?

I recommend this plugin for testing
https://marketplace.atlassian.com/apps/1211542/atlassian-rest-api-browser?hosting=server&tab=overview

I'll checkback later

Best

Tom

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events