0
votes

I am trying to work with a cron job on GCP Cloud Scheduler. I am using the HTTP target with the "GET" method.

I am trying to post messages to a discord channel but first need to GET the body my server webhook sends back to me. The CRON job runs successfully but I cannot find the body of what the webhook returned on the GCP Cloud Scheduler. I have checked the logs as well, it does not contain the body. Here is what the log has:

{
  "insertId": "a06j1cfzy21xe",
  "jsonPayload": {
    "targetType": "HTTP",
    "jobName": "projects/website-274422/locations/us-central1/jobs/discord_sec_bot",
    "url": "https://discordapp.com/api/webhooks/<redacted>/<redacted>",
    "@type": "type.googleapis.com/google.cloud.scheduler.logging.AttemptFinished"
  },
  "httpRequest": {
    "status": 200
  },
  "resource": {
    "type": "cloud_scheduler_job",
    "labels": {
      "project_id": "website-274422",
      "job_id": "discord_sec_bot",
      "location": "us-central1"
    }
  },
  "timestamp": "2020-08-10T21:42:13.290867117Z",
  "severity": "INFO",
  "logName": "projects/website-274422/logs/cloudscheduler.googleapis.com%2Fexecutions",
  "receiveTimestamp": "2020-08-10T21:42:13.290867117Z"
}

Could anyone tell me where I could find what my GET request received?

1
If you select GET method, there are no options for attaching a body; GET requests don't have a body. Try with POST insteadAbrar Hossain

1 Answers

0
votes

Although it's not mentioned directly in the documentation I don't think it's possible to see this. I am not sure what do you want to do, however if you need any information to pass to the logs you can use response status. I have done quick test on my cloud function, which was randomly sending response status from 200 to 204.

For each job I get 2 different log items. In the 2nd one there is following field with random status:

httpRequest: {
  status: 201   
 }

According this is only chance to see anything returned by the endpoint to logs. You can use this status to code some information.