Vibhor Jain
Vibhor Jain

Reputation: 1476

Pubsub API Explorer : Incorrect message data returned

I'm learning PubSub APIs. I published few messages to the Topic and when I used API Explorer to do subscriber pull

Method: projects.subscriptions.pull the data does not seem to match what I actually published:

(attach screenshot)

Oddly, when using actual API (Python Client Library) to do subs pull, things are fine:

subscriber = pubsub_v1.SubscriberClient()
subscription_path = subscriber.subscription_path(PROJECT_ID, SUBSCRIPTION)
messages = subscriber.pull(subscription_path, max_messages=10, timeout=10, return_immediately=True)
print(messages.received_messages[0])

ack_id: "QV5AEkw2AERJUytDCypYEU4EISE-MD5FU0RQBhYsXUZIUTcZCGhRDk9eIz81IChFEAtTE1FcdhNaEGszXHUHUQ0YdHhncGgOQFMAEFl-VVsJPGh-Y3QAVwUfen5pdWJTGgQARHv7z4Dzvb9LZhg9XBJLLD5-PTVF"

message

{ data: "Message number 13"

message_id: "176868380899521"

publish_time {

seconds: 1535000824

nanos: 625000000
}

}

enter image description here

Upvotes: 2

Views: 67

Answers (1)

Christopher P
Christopher P

Reputation: 1108

Pubsub returns your data base64 encoded. It's necessary to decode this in order to retrieve the published message in its original form.

Upvotes: 1

Related Questions