Setting issue parent in planio/redmine when creating issue through API

22 views Asked by At

I am trying to create issues using the the planio API. The documentation states that it is 100% compatible with the redmine-API and during my experiments I also referred to that one so I included redmine into the title. I have been able to set things like subject, description and so on but I struggle to set a parent-issue which is one of the core features I would like to use.

My relevant code in js looks like this:

export async function handleCreateIssue(project, issue) {
    await refreshAuthTokenIfNecessary();
    if (!issue.fixed_version_id) {
        issue.fixed_version_id = await getMostRecentSprintId(project);
    }

    if (!issue.assigned_to_id) {
        issue.assigned_to_id = await getCurrentUserId();
    }

    fetch(`${PLANIO_BASE_URL}/projects/${project}/issues.json`, {
        method: 'POST',
        headers: {
            'Authorization': `Bearer ${getAccessToken()}`,
            'Content-Type': 'application/json',
        },
        body: JSON.stringify({ issue }),
    })
    .then((response) => response.json())
    .then((data) => {
        console.log(chalk.white('  API Response:'), data);
    })
    .catch((error) => {
        console.error('  API Request Error:', error);
    });
}

export class IssueBuilder {
    constructor() {
        this.issue = {};
    }

    withTitle(title) {
        if (!title) {
            return this;
        }
        this.issue.subject = title;
        return this;
    }

    withDescription(description) {
        if (!description) {
            return this;
        }
        this.issue.description = description;
        return this;
    }

    withSprint(sprintId) {
        if (!sprintId) {
            return this;
        }
        this.issue.fixed_version_id = sprintId;
        return this;
    }

    withAssignee(assigneeId) {
        if (!assigneeId) {
            return this;
        }
        this.issue.assigned_to_id = assigneeId;
        return this;
    }

    withParentIssue(parentIssueId) {
        if (!parentIssueId) {
            return this;
        }
        this.issue.parent_issue_id = parseInt(parentIssueId);
        return this;
    }

    build() {
        return this.issue;
    }
}

Referring to the planio/redmine API-documentation as well as inspecting the responses when listing an issue with a parent that already existed in the system as well as despair I tried to use:

  • issue.parent
  • issue.parent_id
  • issue.parent_issue_id
  • issue.parent.id
  • issue.parent_issue.id

in my builder.

I also tried to set the parent id by not including it in the json-body but setting it directly as a query parameter on the url.

I also verified for my different experiments that the input issue as constructed by the builder actually contained a valid issue id for the parent.

Any ideas what I might be missing?

EDIT: I also checked in the planio admin-panel that the registered application has rights to manage subtasks and relationships between issues.

[Side note: there is no planio-tag available so I only put the relevant redmine-tags on this question]

0

There are 0 answers