Jira Service Management - How to how to fix common errors when using the REST API end points related to approvals

Platform Notice: Data Center - This article applies to Atlassian products on the Data Center platform.

Note that this knowledge base article was created for the Data Center version of the product. Data Center knowledge base articles for non-Data Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

As mentioned in Jira Service Management (JSM) REST API documentation, JSM provides a few REST API end points allowing to either fetch the approval information from a JSM request, or to automatically approve it.

The purpose of this documentation is to list the most common errors you might get while using these end points. The 2 end points that we will focus on in this article are the ones listed below:

  • GET /rest/servicedeskapi/request/{issueIdOrKey}/approval
  • POST /rest/servicedeskapi/request/{issueIdOrKey}/approval/{approvalId}

Environment

Jira Service Management Data Center on any version from 5.7.0.

List of errors and how to fix them 

Errors common to both end points

Error 1

Error Message

This API is experimental.  Experimental APIs are not guaranteed to be stable within the preview period. You must set the header 'X-ExperimentalApi: opt-in' to opt into using this API.

What this error means

As mentioned in this error, these API End points are experimental therefore they are not guaranteed to work as expected. 

How to fix it

To be able to use these end points, you need to make sure to add the X-ExperimentalApi header with the value opt-in to the REST API call.

Error 2

Error Message

{
    "errorMessage": "Cannot find issue",
    "i18nErrorMessage": {
        "i18nKey": "sd.portal.error.issue.not.found",
        "parameters": []
    }
}

What this error means

This error means that the issue key specified in the parameter issueIdOrKey in the URL does not exist in the Jira application. This could be due to various reasons:

  • the issue key used in the URL is incorrect
  • or the issue key was added to the URL in lower case (issue keys are case sensitive). For example, itsd-42 was used instead of ITSD-42

How to fix it

To fix this error, make sure to use an issue key that exists in the JSM application, and that it is all in upper case.

Error 3

Error Message

{
    "errorMessage": "You do not have permission to view this request.",
    "i18nErrorMessage": {
        "i18nKey": "sd.request.view.error.no.permission",
        "parameters": []
    }
}

What this error means

This error means that the user which credentials were used to make the REST API call does not have access to the JSM issue key specified in the URL.

How to fix it

To fix this error:

  • either use the credentials of a user who has access to the JSM request in the REST API call
  • or add the right permissions to the user used to make the REST API call

Error 4

Error Message

{
    "errorMessage": "The request could not be found, or you do not have permission to see it.",
    "i18nErrorMessage": {
        "i18nKey": "sd.attachment.error.issue.not.found",
        "parameters": []
    }
}

What this error means

This error occurs when the JSM Request does not have a Request Type set, as illustrated below:

This usually happens when the request was raised from the Jira UI instead or via the Customer Portal.

How to fix it

To fix this issue, add a value to the Request Type field.

Errors specific to the end point POST /rest/servicedeskapi/request/{issueIdOrKey}/approval/{approvalId}

Error 5

Error Message

"com.sun.jersey.api.MessageException: A message body reader for Java class com.atlassian.servicedesk.api.rest.dto.domain.approval.ApprovalDecisionRequestDTO, and Java type class com.atlassian.servicedesk.api.rest.dto.domain.approval.ApprovalDecisionRequestDTO, and MIME media type application/octet-stream was not found.\n"

The error below might also be seen, in case the Content-Type header is included in the REST API call with the value application/json:

"No content to map to Object due to end of input"

What this error means

This error occurs if the REST API call was sent without a payload (body). As mentioned in the  JSM REST API documentation, a body needs to be included in the API call.

How to fix it

Include a body in the REST API Call:

  • The body below will approve the request without adding a comment to the JSM Request:

    {
        "decision": "approve"
    }
  • The body below will approve the request by adding a comment to the JSM Request:

    {
        "decision": "approve",
        "comment": "Sample comment",
        "commentPublic": true
    }

Error 6

Error Message

"Unrecognized field \"comment\" (Class com.atlassian.servicedesk.api.rest.dto.domain.approval.ApprovalDecisionRequestDTO), not marked as ignorable\n at [Source: org.apache.catalina.connector.CoyoteInputStream@970d4d0; line: 3, column: 17] (through reference chain: com.atlassian.servicedesk.api.rest.dto.domain.approval.ApprovalDecisionRequestDTO[\"comment\"])"

What this error means

This error occurs when the body includes the comment property while JSM is on a version lower than 5.7.0. This property is only compatible with JSM 5.7.0 and higher versions.

How to fix it

2 options:

  • Either update the body to not include any of the comment property:

    {
        "decision": "approve"
    }
  • Or keep the body as it is, and upgrade JSM to 5.7.0 and any higher version

Error 7

Error Message

{
    "errorMessage": "The approval has been decided.",
    "i18nErrorMessage": {
        "i18nKey": "sd.approval.error.decision.was.set",
        "parameters": []
    }
}

What this error means

This error means that the approval which ID was provided in the URL has already been approved or declined, therefore it is not possible to re-approve it (it's considered as a past approval).

How to fix it

This error can only be fixed in the JSM Request has a pending approval. If it does, fetch the ID of the pending approval using the GET request, and include it in the POST request.

(info) Please note that a JSM request might go through multiple approval cycles as illustrated below:

When using the GET request to fetch the list of approvals from this request, make sure to fetch the ID of the approval for which the finalDecision property is set to pending in the JSON response as illustrated below:

"values": [
        {
            "id": "14",
            "name": "Waiting for approval",
            "finalDecision": "pending",
            "canAnswerApproval": true,
            "approvers": [
                {
                    "approver": {
                        "name": "admin",
                        "key": "admin",

...

Error 8

Error Message

{
    "errorMessage": "The approval could not be found.",
    "i18nErrorMessage": {
        "i18nKey": "sd.approval.error.approval.not.exist",
        "parameters": []
    }
}

What this error means

This error means that an incorrect approval ID was specified in the POST request. 

How to fix it

Fetch the ID of the pending approval using the GET request, and include it in the POST request.

Error 9

Error Message

{
    "errorMessage": "You don't have approve permission.",
    "i18nErrorMessage": {
        "i18nKey": "sd.approval.error.approve.permission",
        "parameters": []
    }
}

What this error means

This error means that the user which credentials were used to make the REST API call does not have the permission to approve the JSM issue key specified in the URL. It will happen if this user is not listed in the request approvers' list.

How to fix it

To fix this error:

  • either use the credentials of a user who is part of the approvers' list of the JSM request
  • or add the user used in the REST API call to the approvers' list of the JSM request


Last modified on Nov 29, 2024

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.