Data method resolves with ticket payload where attachment data is missing

Hello,

I have been trying to get the files attached (or at least the filenames/URLs) to a freshservice ticket using:
const response = await client.data.get("ticket");
Getting the ticket is not a problem, but the response object does not contain the attachments: [] like described here:
https://developers.freshservice.com/docs/data-methods/#ticket_details_page

How can I get the ticket attachments in my front-end app?

BR
Thomas

@Thomas_Schick, What you are looking at is the right Data Method.

I just have a couple of questions,

  1. Attachment attribute itself doesn’t appear in the response. Does it happen when the ticket actually doesn’t have an attachment and the app might be expecting an empty array - attachments:"[]"? Or the attribute is absent altogether?
  2. Is it possible to share the code snippet and response you’ve seen? Please feel free to replace any confidential details with dummy values.

Hi Saif,

thanks for the reply.

  1. The attribute is absent altogether. The ticket has an attachment present.

using just this:

function renderApp() {
    var onInit = app.initialized();

    onInit
      .then(function getClient(_client) {
        window.client = _client;
        client.events.on("app.activated", renderAttachments);
      })
      .catch(handleErr);
  }
const response = await client.data.get("ticket");
console.log(response);

This is the ticket, as you can see, it has a .jpg file attached:
Screenshot 2021-05-17 at 10.27.30

1 Like

Hi Thomas,
Sorry for the delayed response.

Have you tried looking at our version 2 documentation?
Try making a get request with Authorization to https://[domain].freshservice.com/api/v2/tickets/[ticket.id], you should be able to find an array in attachments attribute.

Hope it helps,
Teja Kummarikuntla

3 Likes

@Thomas_Schick

I was able to reproduce the issue within Data Method.

Payload not having attachments attribute
ticket:
assoc_asset_id: null
assoc_change_cause_id: null
assoc_change_id: null
assoc_problem_id: null
category: null
cc_email: {cc_emails: Array(0), fwd_emails: Array(0), reply_cc: Array(0), tkt_cc: Array(0)}
created_at: "2021-06-07T06:01:31-04:00"
custom_field:
l1_251003: null
l2_251003: null
l3_251003: null
sample_close_field_251003: null
__proto__: Object
deleted: false
department_id_value: null
department_name: null
description: "I am not a joker if I don't have my lipsick."
description_html: "<div style='font-size: 14px; font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif;'>\n<div>I am not a joker if I don't have my lipsick.</div>\n</div>"
display_id: 16
due_by: "2021-06-09T14:00:00-04:00"
email_config_id: null
frDueBy: "2021-06-07T16:00:00-04:00"
fr_escalated: false
group_id: null
id: 14009390934
impact: 3
impact_name: "High"
isescalated: false
item_category: null
owner_id: null
priority: 2
priority_name: "Medium"
requester_id: 14001210862
requester_name: "Joker"
requester_status_name: "Being Processed"
responder_id: null
responder_name: "No Agent"
source: 3
source_name: "Phone"
spam: false
status: 2
status_name: "Open"
sub_category: null
subject: "My lipstick is missing"
ticket_type: "Incident"
to_email: null
to_emails: null
updated_at: "2021-06-07T06:01:31-04:00"
urgency: 1
urgency_name: "Low"

I will bring this up with :freshservice: team to see if this is considered a bug.

Thanks for sharing here on the forum.

Meanwhile, as @tejakummarikuntla suggested, please see if using the product APIs provided could help.

2 Likes

Thanks @tejakummarikuntla and @Saif

I was able to work around using the authorized request @tejakummarikuntla suggested.

BR,
Thomas

3 Likes