Skip to content

Pubsub publisher.py throws error "unexpected keyword argument 'data'" #1880

Description

@sivadotblog

I am trying to execute the file https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/pubsub/cloud-client/publisher.py

I modified the script in my local machine to include Service Account and that is the only change.
publisher = pubsub_v1.PublisherClient.from_service_account_json("<json key>")

This is what I get when i execute:

python publisher.py siva-poc publish "projects/siva-poc/topics/sample_topic"
Traceback (most recent call last):
File "publisher.py", line 275, in
publish_messages(publisher,args.project_id, args.topic_name)
File "publisher.py", line 93, in publish_messages
future = publisher.publish(topic_path, data=data)
TypeError: publish() got an unexpected keyword argument 'data'

I tried a different operation "publish-with-custom-attributes" but it still complains:

python publisher.py siva-poc publish-with-custom-attributes "projects/siva-poc/topics/sample_topic"
Traceback (most recent call last):
File "publisher.py", line 278, in
args.project_id, args.topic_name)
File "publisher.py", line 125, in publish_messages_with_custom_attributes
topic_path, data, origin='python-sample', username='gcp')
TypeError: publish() got an unexpected keyword argument 'origin'

I am not sure why is it complaining about the argument in the publisher_client.

Could someone help me with this, please?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions