Hi All
I am trying to link issues using API in forge. The issues get linked however I get error that “Unexpected end of JSON input”. And I have attached the screen shot of the error.
Here is the code.
const attachToParent = async (issuesToBeLinked = []) => {
console.log(
attachToParent :: attaching tickets ${issuesToBeLinked.length} tickets
);
for (let i = 0; i < issuesToBeLinked.length; i++) {
console.log(
"attachToParent :: issuesToBeLinked :: ",
issuesToBeLinked[i]
);
const bodyData = `{
"inwardIssue": {
"key": "TJP-196"
},
"outwardIssue": {
"key": "TJP-195"
},
"type": {
"name": "Duplicate"
}
}`;
// console.log("JSON => "+JSON.stringify(bodyData));
const response = await api.asApp().requestJira(route`/rest/api/3/issueLink`, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: bodyData
});
const issueLinkResponse = await response.json();
console.log(Response: ${response.status} ${response.statusText});
console.log(issueLinkResponse=${JSON.stringify(issueLinkResponse)});
}
};
await attachToParent(['TJP-196']);