Forums

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

Calling REST API from a 3rd party app

Drew Nedderman
Contributor
January 4, 2021

I need to create an issue in my JSM project based on some triggers in a 3rd party app, Fresh Service. I'm an admin in Jira and Fresh Service.

I can do all the stuff I need to do in Fresh Service except for getting a 200 back from the REST API.

I'm trying to hit https://decisionlogic.atlassian.net/rest/api/3/issue from Fresh Service using an API Token created specifically for this purpose, but I get a 401 Unauthorized back from Jira. If I switch to using my username and password, I get a 403 back from Jira.

Is the above URL the correct one? If not, how do I find out what I should be using? If so, any thoughts about what I'm doing wrong? I can successfully hit that endpoint and create an issue using Postman using this payload:

 { "fields": {        "summary""Testing Ticket 1",        "issuetype": {            "id""10706"        },        "project": {            "key""DLS"        },        "description": [            "This is the test description."        ]        },        "labels": [            "sales_forecasting"        ]                }

 It doesn't add the label I need, but that may just be my inexperience writing requests.

Thank you!

1 answer

1 accepted

0 votes
Answer accepted
mogavenasan
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.
January 4, 2021

Hi @Drew Nedderman,

Let's focus on the 1st problem which is to create a Jira issue from Fresh Service. I'm not well versed with Fresh Service, so you might need to help me with this.

The fact that you are testing the API calls on Postman indicates that you are on the right path here. If you are able to use Postman to create a Jira issue - this means you have connected all the dots here.

From the REST API doc:

  • 401 - Returned if the authentication credentials are incorrect or missing.
  • 403 - Returned if the user does not have the necessary permission.

The recommended way is to use the API token - just to make sure you are have tested the correct combination, can I know if you have tested the API token via Postman and it works?

If yes, then it might be something to do with the Fresh Service configuration.

Thanks,
Moga

Drew Nedderman
Contributor
January 5, 2021

I'm having some trouble creating the issue using the API token in Postman. I'm using the same payload as in my original question but I'm getting this error and a 400 Bad Request when sending the request:

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

 

I've tried using API Key and Bearer Token as the authorization type and I get the same error each time.

Your note about the 401 and 403 response codes is interesting, but I have admin and project admin permissions in the project I'm using to create the issue.

mogavenasan
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.
January 5, 2021

Hi @Drew Nedderman,

Please try this payload, I hope that Description is not a mandatory field:

{
"fields": {
"summary": "Testing Ticket 1",
"issuetype": {
"id": "10706"
},
"project": {
"key": "DLS"
}
}
}

Just to make sure we are not missing out on anything, are you able to create an issue on the DLS project with the same issue type?

The user account will need to have the Create Issue permission on the DLS project in order to be able to create an issue under the Project.

Thanks,
Moga

Drew Nedderman
Contributor
January 5, 2021

Hi @mogavenasan thank you for your help so far. When using that payload I get:

 

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

 

I'm the project admin, so yet I am able to create issues in the DLS project. The error message above doesn't make sense to me because the field is on the create and edit screens.

mogavenasan
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.
January 5, 2021

@Drew Nedderman, would it be possible for you to share some screenshots of how you are running the API call on the Postman? You can grey out the credentials.

Thanks,
Moga

Drew Nedderman
Contributor
January 6, 2021

@mogavenasanhere are screenshots:

Postman Auth.png

Postman Body.pngThank you!

mogavenasan
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.
January 6, 2021

Hi @Drew Nedderman,

I can think of 2 items here:

  • Make sure you have created the API token from your account, not the API key on the Admin console; API tokens.
  • For the Postman, here is an example of how to include the credentials; this thread.

I hope that this will solve the issue here.

Thanks,
Moga

Drew Nedderman
Contributor
January 7, 2021

Hi @mogavenasan

I can confirm that I used the page you linked above to create the API token.

I reviewed the thread you posted and I'm now able to create issues using the API token from Postman with Basic Auth.

 

I still can't create issues using the Fresh Service call to https://decisionlogic.atlassian.net/rest/api/3/issue when using the same method as in Postman, with my username and my API token as the password. I get a 403.

I've also tried using my Jira credentials as the username and password, but I get a 403.

I've contacted Fresh Service support to help with this.

 

Thank you very much for your help with this!

mogavenasan
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.
January 7, 2021

Heya @Drew Nedderman

Yeap, that is a very good place to reach out to their support - we have verified the API call and it works on Postman.

Glad to know I can help. Please mark this thread as Solved.

Thanks,
Moga

Suggest an answer

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

Atlassian Community Events