Create a file attachment on a case or Cloud resource.
The attachment must have the following fields set: filename
.
EXAMPLES:
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 request
- Upload URI, for media upload requests:
POST https://cloudsupport.googleapis.com/upload/v2/{parent=*/*/cases/*}/attachments
- Metadata URI, for metadata-only requests:
POST https://cloudsupport.googleapis.com/v2/{parent=*/*/cases/*}/attachments
The URL uses gRPC Transcoding syntax.
Path parameters
Parameters | |
---|---|
parent |
Required. The name of the case or Cloud resource to which the attachment should be attached. |
Request body
The request body contains data with the following structure:
JSON representation |
---|
{
"attachment": {
object ( |
Fields | |
---|---|
attachment |
Required. The attachment to be created. |
Response body
If successful, the response body contains an instance of Attachment
.
Authorization scopes
Requires one of the following OAuth scopes:
https://www.googleapis.com/auth/cloudsupport
https://www.googleapis.com/auth/cloud-platform
For more information, see the Authentication Overview.