Site icon TestingDocs.com

Create Issue using Mantis REST API

Overview

Earlier we had a look at reporting an issue using the Mantis Web Interface. In this tutorial, we will learn to create an issue using Mantis Rest API. This approach is useful in Automation. When a testcase fails during automation run. we can automatically create a bug in Automation using this call.

Create Issue using Mantis Web Interface.

https://www.testingdocs.com/report-an-issue-in-mantis-bug-tool/

Postman API Tool

Let’s get started. We will use the Postman API tool to manually invoke the Rest API call. In case you if you are new to Postman tool:

Postman Tool : https://www.testingdocs.com/postman-api-tool/

How to execute an API call:

https://www.testingdocs.com/how-to-execute-rest-api-call-using-postman/

Headers

The API call uses the POST HTTP method. The Post method should have a request body. The content of the body is specified using the ‘Content-Type‘ HTTP request header. We will use the JSON content type for the API call. To specify we will set the Content-Type request header to ‘application/json‘.

 

 

Another header in the call is the Authorization header. The value of the header is the API token of the API caller. Follow this link to get an API token for your Mantis instance:

https://www.testingdocs.com/create-api-token-in-mantisbt/

API Request Body

The request body is the JSON string. It contains the details of the issue that you want to create like the bug summary, bug description, project name, etc.

 

Sample API Request JSON

Issue with minimal details:

{
    "summary": "[TestingDocs.com] This issue is created using POST /issues 
REST API call",
    "description": "This is a sample test bug API Description - ",
    "category": { "name": "General" },
    "project": {   "name": "TestingDocsProject" }
    }

API Response

To execute the call click on the Send button. A successful API response status should be 201 created. Any other status code means that there is an issue with the call, server and the environment.

 

Sample API HTTP Response for the call:

{
    "issue": {
        "id": 4,
        "summary": "[TestingDocs.com] This issue is created using POST /issues
 REST API call",
        "description": "This is a sample test bug API Description - ",
        "project": {
            "id": 1,
            "name": "TestingDocsProject"
        },
        "category": {
            "id": 1,
            "name": "General"
        },
        "reporter": {
            "id": 1,
            "name": "administrator",
            "email": "root@localhost"
        },
        "status": {
            "id": 10,
            "name": "new",
            "label": "new",
            "color": "#fcbdbd"
        },
        "resolution": {
            "id": 10,
            "name": "open",
            "label": "open"
        },
        "view_state": {
            "id": 10,
            "name": "public",
            "label": "public"
        },
        "priority": {
            "id": 30,
            "name": "normal",
            "label": "normal"
        },
        "severity": {
            "id": 50,
            "name": "minor",
            "label": "minor"
        },
        "reproducibility": {
            "id": 70,
            "name": "have not tried",
            "label": "have not tried"
        },
        "sticky": false,
        "created_at": "2019-07-17T10:48:09+00:00",
        "updated_at": "2019-07-17T10:48:09+00:00",
        "history": [
            {
                "created_at": "2019-07-17T10:48:09+00:00",
                "user": {
                    "id": 1,
                    "name": "administrator",
                    "email": "root@localhost"
                },
                "type": {
                    "id": 1,
                    "name": "issue-new"
                },
                "message": "New Issue"
            }
        ]
    }
}

We can notice the the Bug id created is 4. The bug is created with minor severity and normal priority.

Verification

Log in to the Mantis Web interface and verify with the Bug id from the API response.

 

Rest API Automation

https://www.testingdocs.com/rest-api-automation-with-karate-automation-tool/

Automate POST call with Karate

https://www.testingdocs.com/test-post-api-request-with-karate-framework/

Mantis Bug Tracker Tutorial

https://www.testingdocs.com/mantis-bug-tracker-tutorial/

Mantis Website:

https://www.mantisbt.org/

 

Exit mobile version