cancel
Showing results for 
Search instead for 
Did you mean: 

SAP Cloud Platform Job Scheduler - Update Job Run Log

fabianorosa
Participant
0 Kudos

Hi all,

I have a node.js scheduled as a TASK in SAP Cloud Platform Job Scheduler service, and I need to call the Job Scheduler API to update the status of an asynchronous, long-running job, and based on the below documentation I need to call a REST service:

Update Job Run Log

PUT /scheduler/jobs/ {jobId}/schedules/{scheduleId}/runs/{runId}

How can I receive, inside on the node.js application, the values of jobId, scheduleId and runId from the running task?

Regards,

Fabiano Rosa

Accepted Solutions (1)

Accepted Solutions (1)

CarlosRoggan
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello Fabiano,

sorry for the late reply.
In case of Task, Jobscheduler will set the status automatically. It is not possible to set the status from the node.js code.
So in this case it is different from what is done in case of async "Jobs"
Kind Regards,
Carlos

Answers (2)

Answers (2)

fabianorosa
Participant
0 Kudos

Hi Saha,

You need to follow these main steps:

  1. Schedule the node.js as a JOB and not a TASK in BTP Job Schedule service.
  2. Get the XSUAA instance from BTP Job Schedule ("const jobSchedulerService = xsenv.getServices({ jobScheduler: { tag: 'jobscheduler' } });"). You will need it to get the JWT token to execute the PUT request for update the status of the job.
  3. Inside you function in the Node.js job (rest endpoint), you need to retrieve the headers ("req.headers") from the request with the job execution information. Ex: const jobId = headers['x-sap-job-id'];
  4. When you finish the job, you need to update the Job status sending the JWT token and the required parameters to the BTP Job Scheduler endpoint (`/scheduler/jobs/${jobId}/schedules/${scheduleId}/runs/${runId}`).

Regards,

Fabiano Rosa

fabianorosa
Participant
0 Kudos

Hi Carlos, thanks for checked it internally in SAP. I already moved from Task to Job, and it worked!

Also, I validated the Cedric’s approach from this blog post and worked as expect with XSUAA:

https://blogs.sap.com/2020/10/01/application-to-multiple-xsuaa-services-replace-whitelisting-of-sap_...

Regards,

Fabiano Rosa

ritushree
Explorer
0 Kudos

Hi Fabiano ,

We have a node.js scheduled as a job in SAP Cloud Platform Job Scheduler service, and we need to call the Job Scheduler API to update the status of an asynchronous, long-running job, and based on the below documentation -

Update Job Run Log

PUT /scheduler/jobs/ {jobId}/schedules/{scheduleId}/runs/{runId} .

I find that you have already found the solution . Could you please share the same as to if the same can be done in node.js f

Thanks in advance .

Ritushree