I'm setting up Pub/Sub for my Android Management API
solution, I have created a Topic
& Subscription
to create a ENROLLMENT
notification. The subscription is of type PULL
so when I pull it works as expected and shows the enrollment notifications.
I want to use Delivery type
as PUSH
and hit a POST API
which will add the details of this newly enrolled device into my DB.
Can I use the POST API URL
something like https://abc.dcd.com:8008/api/PubTest
as the Endpoint URL
? If so how can I test it using debugger ?
I was unable to find any tutorial in C# to do the same.
Thanks in advance!
I don’t see anything obviously wrong with using something like https://abc.dcd.com:8008/api/PubTest
as the endpoint URL. A Pub/Sub push request looks like the following (note that the message.data
field is base64-encoded).
POST https://abc.dcd.com:8008/api/PubTest
{
"message": {
"attributes": {
"key": "value"
},
"data": "SGVsbG8gQ2xvdWQgUHViL1N1YiEgSGVyZSBpcyBteSBtZXNzYWdlIQ==",
"messageId": "136969346945"
},
"subscription": "projects/MY_PROJECT/subscriptions/MY_SUBSCRIPTION"
}
To configure your subscription to deliver messages to a push endpoint, you can configure it directly in the Google Cloud Console via the ‘Create subscription’ or ‘Edit subscription’ page.
Screenshot of the Google Cloud Console's 'Edit subscription' page
You can also configure your subscription using gcloud.
$ gcloud pubsub subscriptions update \
projects/MY_PROJECT/subscriptions/MY_SUBSCRIPTION \
--push-endpoint https://abc.dcd.com:8008/api/PubTest
For more information, please refer to the following guide for using push subscriptions: https://cloud.google.com/pubsub/docs/push