Unable to get attachment content

Hi,
While calling Get attachment content method, it gives me exception.
Here is example on api documentation.

const response = await api.asApp().requestJira(route`/rest/api/3/attachment/content/{id}`, {
  headers: {
    'Accept': 'application/json'
  }
});

console.log(`Response: ${response.status} ${response.statusText}`);
console.log(await response.json());

and here is my code:

  const response = await api
    .asUser()
    .requestJira(route`/rest/api/3/attachment/content/${id}`, {
      headers: {
        Accept: "application/json",
      },
    });

  console.log(`Response: ${response.status} ${response.statusText}`);
  console.log(await response.json());

and this is exception I receive:

I also tried second method: Get attachment metadata, and its not going on exception but in response there missing mediaApiFileId property.

1 Like

Hi @NikaKhvichia,

The response you are jetting is not in a JSON format for some reason. Could you please change the last line to

console.log(await response.text());

so the output is printed as text to avoid JSON parsing error?

Thanks,
Vitalii

Hi @vpetrychuk

I’m writing on behalf of @NikaKhvichia. Thanks for your reply. We have also tried what you have proposed and it works.

Another issue that Nika mentioned is the missing property mediaApiFileId in the response of Get attachment metadata method. Can you please advise on this?

Regards,
Gia

Hi @GiaJgarkava,

I’m glad to hear it works! The second problem looks like a bug to me. There are a few known issues with attachments in Forge and this might be another one. The only thing I could do here at the moment is to report it to the team so they fix it (after prioritizing it).

Thanks,
Vitalii

I’ve raised a public ticket to track: Log in with Atlassian account

Thanks, Vitalii!

We’ll track the issue, though yet we’re not able to access the ticket with our Atlassian accounts:

.

Best regards,
Gia

Interesting. @ccurti any ideas why the BUILD project isn’t publicly available?

@GiaJgarkava @vpetrychuk try this one: [FRGE-587] mediaApiFileId property is not returned from Get attachment metadata REST API - Ecosystem Jira

The BUILD project is for internal tracking while the FRGE projet is where the issues/suggestions related to Forge can be found.

Cheers,
Caterina

1 Like

Hi Caterina.

Thanks, we were able to access the provided link.

Regards,
Gia