I want to create a cronjob that interacts with my API. First, I need to send a request to authentificate, then send a GET request
Here is the yaml of my cronjob:
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: verification-pointage
namespace: isi-incubator
spec:
schedule: "*/1 * * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: verification-pointage
image: curlimages/curl:7.77.0
imagePullPolicy: IfNotPresent
command: ["/bin/sh","-c"]
args: ["curl -c session -H \"Content-Type:application/json\" -d '{\"username\":\"johndoe\",\"password\":\"johndoe123\"}' http://odoo-api/authentication && curl -b session http://odoo-api/timesheets/verification"]
restartPolicy: OnFailure
When I do the two curl commands in local, I have no problem, but when the commands are executed in the cronjob, the session
doesn't seem to have been created. So the second command cannot use the cookie stored in the session file.