Download an attachment
GET/v1/tickets/{number}/attachments/{attachmentId}/contentScope read
The content of an attachment, as a file.
Path parameters
Section titled “Path parameters”| Name | Type | Description |
|---|---|---|
number required |
string |
Request number, such as GM-000123. |
attachmentId required |
string |
ID of the attachment, from List attachments. |
Response
Section titled “Response”200 OK. The response is the file itself, with its Content-Type and a Content-Disposition attachment header.
Errors
Section titled “Errors”Errors share one shape; see Errors for every key.
Code examples
Section titled “Code examples”curl 'https://api.client.service-desk.goldmaster.io/v1/tickets/GM-000123/attachments/88/content' \ -H "Authorization: Bearer $DUTY_API_KEY" \ -o attachment.binimport { writeFile } from 'node:fs/promises';
const response = await fetch('https://api.client.service-desk.goldmaster.io/v1/tickets/GM-000123/attachments/88/content', { method: 'GET', headers: { Authorization: `Bearer ${process.env.DUTY_API_KEY}`, },});if (!response.ok) throw new Error(`Duty API ${response.status}`);await writeFile('attachment.bin', Buffer.from(await response.arrayBuffer()));import os
import requests
response = requests.request( "GET", "https://api.client.service-desk.goldmaster.io/v1/tickets/GM-000123/attachments/88/content", headers={"Authorization": f"Bearer {os.environ['DUTY_API_KEY']}"}, timeout=30,)response.raise_for_status()with open("attachment.bin", "wb") as file: file.write(response.content)package main
import ( "fmt" "io" "net/http" "os")
func main() { req, _ := http.NewRequest("GET", "https://api.client.service-desk.goldmaster.io/v1/tickets/GM-000123/attachments/88/content", nil) req.Header.Set("Authorization", "Bearer "+os.Getenv("DUTY_API_KEY")) res, err := http.DefaultClient.Do(req) if err != nil { panic(err) } defer res.Body.Close() data, _ := io.ReadAll(res.Body) os.WriteFile("attachment.bin", data, 0o644) fmt.Println(res.Status)}<?php$ch = curl_init('https://api.client.service-desk.goldmaster.io/v1/tickets/GM-000123/attachments/88/content');curl_setopt_array($ch, [ CURLOPT_CUSTOMREQUEST => 'GET', CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => [ 'Authorization: Bearer ' . getenv('DUTY_API_KEY'), ],]);$response = curl_exec($ch);$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);file_put_contents('attachment.bin', $response);using System.Net.Http.Headers;
using var client = new HttpClient();using var request = new HttpRequestMessage(new HttpMethod("GET"), "https://api.client.service-desk.goldmaster.io/v1/tickets/GM-000123/attachments/88/content");request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("DUTY_API_KEY"));using var response = await client.SendAsync(request);await File.WriteAllBytesAsync("attachment.bin", await response.Content.ReadAsByteArrayAsync());import java.net.URI;import java.net.http.*;import java.nio.file.*;
HttpClient client = HttpClient.newHttpClient();HttpRequest request = HttpRequest.newBuilder(URI.create("https://api.client.service-desk.goldmaster.io/v1/tickets/GM-000123/attachments/88/content")) .header("Authorization", "Bearer " + System.getenv("DUTY_API_KEY")) .method("GET", HttpRequest.BodyPublishers.noBody()) .build();var response = client.send(request, HttpResponse.BodyHandlers.ofFile(Path.of("attachment.bin")));System.out.println(response.statusCode() + " " + response.body());