Forbidden when trying to call Service Desk API from Connect App

Hello!

I am sorry to bother. I have been performing calls from my Connect App to the Service Desk API without issues, but this morning I realized one call is failing in one of my environments.

I am using this endpoint: https://developer.atlassian.com/cloud/jira/service-desk/rest/api-group-requesttype/#api-rest-servicedeskapi-requesttype-get

The connect application has READ scope, and I am performing the call from my back end, like this:

addon.httpClient(req).get({
    url: `/rest/servicedeskapi/requesttype?searchQuery=`,
    helpers: {
      'X-ExperimentalApi': 'opt-in'
    }
  }, function (err, res, body) {
    console.log(res.statusCode)
    console.log(res.statusMessage)
  });

The call is failing with Forbidden (403) status.
Any idea what could be possibly failing?

Thank you!

1 Like

Hi, have you managed to reach this endpoint?

Hi @veloti It fixed itself eventually, but now I installed the app in a fresh instance and I am seeing the error again. Were you able to figure it out? Thank you! (I am the OP, but with a different account)

Hi @vertexar , try this out, it works for me:

app.get('/requesttypes', addon.checkValidToken(), async (req, res) => {
		const httpClient = addon.httpClient(req);

		try {
			httpClient.get({
				url: '/rest/servicedeskapi/requesttype?searchQuery=',
				contentType: 'application/json',
				headers: {
					"X-ExperimentalApi": "opt-in"
				}
			}, function (err, response, body) {
				const code = response.statusCode
				const values = JSON.parse(response.body)
				if (code === 201 || code === 200) {
					res.status(code).send({ values })
				}
			})
		} catch (error) {
			res.status(503).send({
				message: e.message
			})
		}
	})
1 Like

@veloti Than you! I completely missed your response and yesterday I found myself encountering this error again in a fresh instance. In this new instance, the code you shared raised the same error. Turned out it was because JSM wasn´t installed in that new instance, and this endpoint only works when you have installed Jira Service Management.
I am leaving this note here in case someone else encounters this problem.
Thank you my friend!

2 Likes