Hi,
I am trying to create a small extension for JIRA Cloud using Forge and I am trying to create Issue on web-trigger event on certain condition. Can anyone point out what obvious thing I am missing
I am getting the following error
errorMessages: [
'Can not deserialize instance of com.atlassian.jira.rest.v2.issue.IssueUpdateBean out of START_ARRAY token\n' +
' at [Source: org.apache.catalina.connector.CoyoteInputStream@46216db3; line: 1, column: 1]'
]
the payload I am using for is
`{
update: {},
fields: {
summary: 'Create this story issue',
type: 'doc',
parent: { key: 'SPLIT' },
issuetype: { id: '10004' },
project: { id: '10000' },
description: { type: 'doc', version: 1, content: [
{
type: "paragraph",
content: [
{
text: "As a User, I want to...",
type: "text",
},
],
},
], }
}
}`
1 Like
Two things that come to my mind:
- Make sure that you are using api version 3
- Stringify the payload before sending it
Our app (Easy Subtask Templates) creates subtasks like so:
api.asUser().requestJira("/rest/api/3/issue", {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify(payload)
})
1 Like
@jmadan I’m having trouble making sense of the error message you’re getting back. Can you share the function code where you’re calling the API?
1 Like
Hi @rwhitbeck,
here is the code
const postIssue = async (issue) => {
const response = await api.asApp().requestJira("/rest/api/3/issue", {
method: "POST",
headers: {
Accept: "application/json",
"Content-Type": "application/json",
},
body: issue,
});
console.log(`Response: ${response.status} - ${response.statusText}`);
return await response.json();
};
the payload I am passing to this function is
`{
update: {},
fields: {
summary: 'Create this story issue',
type: 'doc',
parent: { key: 'SPLIT' },
issuetype: { id: '10004' },
project: { id: '10000' },
description: { type: 'doc', version: 1, content: [
{
type: "paragraph",
content: [
{
text: "As a User, I want to...",
type: "text",
},
],
},
], }
}
}`
The payload you passing to the function is no perfectly valid JSON string. Have to tried converting it to a string using JSON.stringify?
const payload = {
update: {},
fields: {
summary: 'Create this story issue',
type: 'doc',
parent: { key: 'SPLIT' },
issuetype: { id: '10004' },
project: { id: '10000' },
description: { type: 'doc', version: 1, content: [
{
type: "paragraph",
content: [
{
text: "As a User, I want to...",
type: "text",
},
],
},
], }
}
};
await postIssue(JSON.stringify(payload));
thanks. JSON.stringify it produces the following error even though I am trying to create an issue.
{
errorMessages: [],
errors: { parent: 'Could not find issue by id or key.' }
}
payload is
{
update: {},
fields: {
summary: 'Create this story issue',
parent: { key: 'SPLIT' },
issuetype: { id: '10004' },
project: { id: '10000' },
description: {
type: 'doc',
version: 1,
content: [
{
type: "paragraph",
content: [
{
text: "As a User, I want to...",
type: "text",
},
],
},
]
}
}
}
looks like you are providing an invalid “parent” value.
parent: { key: 'SPLIT' }
does not look like a valid reference to an issue. Parent is used for subtasks while “SPLIT” looks like the key of a project. You are already referencing a project by it’s id (10000).
You can remove the “parent” part of the payload or (if you want to create subtasks) use a valid issue key.
1 Like
Thanks @JulianWolf much appreciated.
It works
1 Like