Method: media.upload

Erstellen Sie einen Dateianhang für eine Supportanfrage oder eine Cloud-Ressource.

Für den Anhang müssen die folgenden Felder festgelegt sein: filename.

BEISPIELE:

cURL:

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())

HTTP-Anfrage

  • Upload-URI für Medienuploadanfragen:
    POST https://cloudsupport.googleapis.com/upload/v2/{parent=*/*/cases/*}/attachments
  • Metadaten-URI, für Nur-Metadaten-Anfragen:
    POST https://cloudsupport.googleapis.com/v2/{parent=*/*/cases/*}/attachments

Die URL verwendet die Syntax der gRPC-Transcodierung.

Pfadparameter

Parameter
parent

string

Erforderlich. Der Name des Falls oder der Cloud-Ressource, an die der Anhang angehängt werden soll.

Anfragetext

Der Anfragetext enthält Daten mit folgender Struktur:

JSON-Darstellung
{
  "attachment": {
    object (Attachment)
  }
}
Felder
attachment

object (Attachment)

Erforderlich. Der zu erstellende Anhang.

Antworttext

Wenn der Vorgang erfolgreich abgeschlossen wurde, enthält der Antworttext eine Instanz von Attachment.

Autorisierungsbereiche

Erfordert einen der folgenden OAuth-Bereiche:

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

Weitere Informationen finden Sie in der Authentifizierungsübersicht.