google-apigoogle-client

Storage Transfer Service transferJobs.patch API does not work for nested object


Problem you have encountered:

  1. Following steps at link below for transferJobs.patch API
    https://cloud.google.com/storage-transfer/docs/reference/rest/v1/transferJobs/patch
  2. Patch API works as expected if want to update description. Sample Below Request:
    {
  "projectId": "<MY_PROJECT>",
  "transferJob": {
    "transferSpec": {
      "objectConditions": {
        "lastModifiedSince": "2022-01-24T18:30:00Z"
      }
    },
    "description": "updated description"
  },
  "updateTransferJobFieldMask": "description"
}

Response: Success 200

  1. Patch API do not work if want to update nested object field. Sample Below
    {
  "projectId": "<MY_PROJECT>",
  "transferJob": {
    "transferSpec": {
      "objectConditions": {
        "lastModifiedSince": "2022-01-22T18:30:00Z"
      }
    },
    "description": "updated description"
  },
  "updateTransferJobFieldMask": "transferSpec.objectConditions.lastModifiedSince"
}

Response: 400

{"error": {
"code": 400,
"message": "Invalid path in the field mask.",
"status": "INVALID_ARGUMENT"}}

Tried other combinations following documentation/sample code reference but none of them work. Tried options as

What I expected to happen:

Patch API to work successfully for nested object as per documentation I.e. "updateTransferJobFieldMask": "transferSpec.objectConditions.lastModifiedSince"


Solution

  • updateTransferJobFieldMask works on the top level object, in this case transferSpec.

    Changing that line to updateTransferJobFieldMask: transferSpec should work.

    From the documentation:

    The field mask of the fields in transferJob that are to be updated in this request. Fields in transferJob that can be updated are: description, transfer_spec, notification_config, and status. To update the transfer_spec of the job, a complete transfer specification must be provided. An incomplete specification missing any required fields will be rejected with the error INVALID_ARGUMENT.