0
votes

I am trying Google Cloud API Explorer for

Services > Cloud Pub/Sub API v1 > pubsub.projects.subscriptions.pull

Request

POST https://pubsub.googleapis.com/v1/projects/mimic-integration-10-2019/subscriptions/telemetry:pull?key={YOUR_API_KEY}

{ }

and it fails with

Response

400 Bad Request

  • Show headers -

{ "error": { "code": 400, "message": "You have passed an invalid argument to the service (argument=max_messages).", "status": "INVALID_ARGUMENT" } }

What am I doing wrong? Other calls like Services > Cloud Pub/Sub API v1 > pubsub.projects.subscriptions.list work fine.

1
Authorization Scopes Requires one of the following OAuth scopes:["googleapis.com/auth/pubsub", "googleapis.com/auth/cloud-platform"] Do you have the correct OAuth scopes? Where do you get {YOUR_API_KEY} from? - DUDANF
As I indicated, other calls work. So, it's not an authentication problem. - Gambit Support
I just looked at the API more closely, and there are some hidden arguments. Closed. - Gambit Support

1 Answers

0
votes

Looked at the API

https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions/pull

more closely, and there are 2 hidden arguments. Would be nice if the explorer did not hide them.

Works, once I provide the arguments:

Request

POST https://pubsub.googleapis.com/v1/projects/mimic-integration-10-2019/subscriptions/telemetry:pull?key={YOUR_API_KEY}

{ "returnImmediately": true, "maxMessages": 10 }

Response

200 OK

  • Show headers -

{ "receivedMessages": [ { "ackId": "WBFOBCEhPjA-RVNEUAYWLF1GSFE3GQhoUQ5PXiM_NSAoRRULUxNRXHUCRRBsVTN1B1ENGXN7NSY7UhsCBUcBdF9RGx9ZXH5KAFkEGHZ7ZXNiXBIACkNWVp_9-5a3oQ9vPGm409OgVFXLkN0hZhs9XBJLLD5-PTNFQV5AEkw2BkRJUytDCyo", "message": { "data": "eyJzbiI6IjIwOjE5OkFCOkY0OjI3OjFCIiwiZGF0YSI6eyJhY2MiOnsieCI6MjYsInkiOjMyLCJ6IjoxMDEyLCJ1bml0IjoibUcifSwiZ3lybyI6eyJ4IjoxMjIwLCJ5IjotNjgzNSwieiI6LTIzMTksInVuaXQiOiJtZGVnL3MifSwibWFnIjp7IngiOjQwLCJ5IjoxLCJ6IjotNCwidW5pdCI6InVUIn0sImxpZ2h0Ijp7InZhbHVlIjoxMzU1NywidW5pdCI6Im1MdXgifSwidGVtcCI6eyJ2YWx1ZSI6NTAwMDAsInVuaXQiOiJtQ2Vsc2l1cyJ9LCJwcmVzc3VyZSI6eyJ2YWx1ZSI6OTg4OTcsInVuaXQiOiJQYXNjYWwifSwiaHVtaWRpdHkiOnsidmFsdWUiOjM5LCJ1bml0IjoiJXJoIn19fQ==", "attributes": { "projectId": "mimic-integration-10-2019", "deviceId": "mimic1", "deviceNumId": "2683064391811245", "deviceRegistryId": "mimic-registry", "deviceRegistryLocation": "us-central1", "subFolder": "" }, "messageId": "789146468611865", "publishTime": "2019-10-14T13:49:47.862Z" } } ] }