I have created a Google Cloud Function using Python 3.7. Testing the function itself, it behaves as expected. I have set the trigger of the function to be a topic called "Scheduled".
The code itself runs a series of API calls, when tested manually from the UI works exactly as expected. Output when running a manual test. The original source code requires no arguments for the main function inside the script, however I realized the Cloud Function passes 2 to it anyway, so I have added them with no actual use:
def main(event, data):
print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
getNotifs = getNotifications()
if getNotifs["hasData"] == True:
print("Found notifications, posting to Telegram.")
notifsParsed = parseNotifications(getNotifs["data"])
telegramCall = telegramPost(
{"text": str(notifsParsed), "chat_id": ChatId, "parse_mode": "HTML"})
print(telegramCall)
elif getNotifs["hasData"] == False:
print(getNotifs["error"])
print("================================")
Now, I have created a new Cloud Scheduler job where the target is "pub/sub" and the topic is also "Scheduled". Nowhere could I find a use for the required 'payload' field, and the Scheduler guide by Google only fills in a random value, 'hello' without quotes or something like it, so I filled in 'hi'.
Running the job I am repeatedly met with a failure, and this log:
status: "INVALID_ARGUMENT"
targetType: "PUB_SUB".
I have tried changing the payload to "hi" (with quotes), editing the main PY function to accept one more argument, both seem entirely unrelated. What am I missing?