Claudio LoBraico
Claudio LoBraico

Reputation: 31

Xray api/v2/import/feature endpoint flaky when input feature file has > 10 scenarios

Description

I'm currently using the Xray api/v2/import/feature endpoint with multiform data to import gherkin feature files into Jira. I've observed that when the number of scenarios in the feature file exceeds 10, I hit a 400 error with the message Issue create failed!. This only seems to arise when the number of scenarios exceeds 10, otherwise, I do not have any issues importing the feature/scenarios.

Feature file with an associated jira issue (indicated by the tag at the top):

@KEY-12345
Feature: New Feature 
    As a stakeholder
    I want a new feature
    So that I can use some functionality that serves some business purpose
    
    Scenario: New Scenario 0 
        Given some inputs
        When I do something
        Then I get some outputs
    .
    .
    .
    .
 
    Scenario: New Scenario 12
        Given some inputs
        When I do something
        Then I get some outputs

Import feature script

import requests
XRAY_BASE_URL = "https://xray.cloud.getxray.app/"

def import_feature(project_key, feature_file_path, auth_token):
    file = {
        "file": (
            feature_file_path,
            open(feature_file_path, "rb"),
            "application/octet-stream",
        ),
    }
    response = requests.post(
        XRAY_BASE_URL + "api/v2/import/feature",
        headers={"Authorization": f"Bearer {auth_token}"},
        params={
            "projectKey": project_key,
            "issueType": "Test",
        },
        files=file,
    )
    response.raise_for_status()
    return response

Expected behavior

Scenarios are successfully imported and linked to the parent issue.

Actual behavior

Only some of the scenarios are successfully imported and the response returns 400: issue create failed!

Upvotes: 0

Views: 43

Answers (0)

Related Questions