Method: media.upload

Buat lampiran file pada kasus atau resource Cloud.

Lampiran harus memiliki kolom berikut yang disetel: filename.

CONTOH:

{i>cURL<i}:

echo "This text is in a file I'm uploading using CSAPI." \
  > "./example_file.txt"
case="projects/some-project/cases/43594844"
curl \
  --header "Authorization: Bearer $(gcloud auth print-access-token)" \
  --data-binary @"./example_file.txt" \
  "https://cloudsupport.googleapis.com/upload/v2beta/$case/attachments?attachment.filename=uploaded_via_curl.txt"

Python:

import googleapiclient.discovery


apiVersion = "v2"
supportApiService = googleapiclient.discovery.build(
    serviceName="cloudsupport",
    version=apiVersion,
    discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version={apiVersion}",
)

file_path = "./example_file.txt"
with open(file_path, "w") as file:
    file.write(
        "This text is inside a file I'm going to upload using the Cloud
        Support API.",
    )

request = supportApiService.media().upload(
    parent="projects/some-project/cases/43595344",
    media_body=file_path
)
request.uri = request.uri.split("?")[0] +
"?attachment.filename=uploaded_via_python.txt" print(request.execute())

Permintaan HTTP

  • URI upload, untuk permintaan upload media:
    POST https://cloudsupport.googleapis.com/upload/v2beta/{parent=*/*/cases/*}/attachments
  • URI Metadata, untuk permintaan khusus metadata:
    POST https://cloudsupport.googleapis.com/v2beta/{parent=*/*/cases/*}/attachments

URL menggunakan sintaks gRPC Transcoding.

Parameter jalur

Parameter
parent

string

Wajib. Nama kasus atau resource Cloud tempat lampiran harus dilampirkan.

Isi permintaan

Isi permintaan memuat data dengan struktur berikut:

Representasi JSON
{
  "attachment": {
    object (Attachment)
  }
}
Kolom
attachment

object (Attachment)

Wajib. Lampiran yang akan dibuat.

Isi respons

Jika berhasil, isi respons akan berisi instance Attachment.

Cakupan otorisasi

Memerlukan salah satu cakupan OAuth berikut:

  • https://www.googleapis.com/auth/cloudsupport
  • https://www.googleapis.com/auth/cloud-platform

Untuk informasi selengkapnya, lihat Ringkasan Autentikasi.