Trying to download attachment

Hi i am trying to clone an issue using rest api adn for the attachment part i am using attachment.content to download the attachment but i am getting an error Disallowing path manipulation attempt. const downloadRes = await api.asApp().requestJira(route${baseUrl}/rest/api/3/attachment/content${contentId}, {
method : “GET”,
headers: {
// Add authorization if needed
‘Authorization’: Basic ${authToken}
}
});
console.log(downloadRes ,"check res ")
if (!downloadRes.ok) {
throw new Error(Failed to download attachment: ${downloadRes.status});
}

Hi @Ankitkharola1 ,

When your code is running on the Forge platform, you don’t need to prefix API requests with the Base URL. You also don’t need to provide an Authorization header. The platform handles both of these automatically.

The actual error you are receiving (‘disallowing path manipulation attempt’) comes from the route function identifying potential URL traversal vulnerabilities. This thread has more info: Disallowing path manipulation attempt - #3 by AlexeyKotlyarov

Try something like this instead:

const downloadRes = await api.asApp().requestJira(route`/rest/api/3/attachment/content/${contentId}`);

console.log(downloadRes ,"check res ")
if (!downloadRes.ok) {
    throw new Error(Failed to download attachment: ${downloadRes.status});
}