question

Upvotes
Accepted
17 5 5 11

Python code to cancel executing TRTH jobs

I have some jobs pending for over a week and wanted to just cancel them. Looking for a python implementation. Thanks!

screen-shot-2023-03-02-at-70443-pm.png

I tried looking here:

https://community.developers.refinitiv.com/questions/34724/cancelling-executing-job-1.html
https://community.developers.refinitiv.com/questions/65945/cancel-queued-up-trth-jobs.html






python#producttrth-rest-api
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Hello @ns3481

Thank you for your participation in the forum. Is the reply below satisfactory in resolving your query?


If so please can you click the 'Accept' text next to the appropriate reply? This will guide all community members who have a similar question.

Thanks,


AHS


Please be informed that a reply has been verified as correct in answering the question, and has been marked as such.

Thanks,


AHS


Upvotes
Accepted
78.6k 248 52 74
@ns3481

Are they on-demand extractions or scheduled extractions?

You may need to contact the Tick History support team directly via MyRefinitiv to verify these jobs.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
14.1k 30 5 10

Hi @ns3481 ,

Could you try the below? or please let me know if you use other endpoints

DELETE https://selectapi.datascope.refinitiv.com/RestApi/v1/Extractions/ExtractRawResult(ExtractionId='<job ID>')

The Python code looks like this

import requests
import json

url = "https://selectapi.datascope.refinitiv.com/RestApi/v1/Extractions/ExtractRawResult(ExtractionId='<job ID>') "

payload = ""
headers = {
  'Prefer': 'respond-async, wait=1',
  'Content-Type': 'application/json',
  'Authorization': 'Token <valid token>'
}

response = requests.request("DELETE", url, headers=headers, data=payload)

print(response.text)
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
17 5 5 11

@raksina.samasiri For some reason, I can't comment on your response. Thanks for the quick turnaround. This does not work for me. here's the code, pretty much along the lines of what you suggested:

import requests
import json

for job_id in ['0x085fd0a65058920c', '0x085fd1335fd8929f', '0x085fd1335f68929f', '0x085fd0a64658920c']:
    url = "https://selectapi.datascope.refinitiv.com/RestApi/v1/Extractions/ExtractRawResult(ExtractionId='{}') ".format(job_id)

    payload = ""
    headers = {
      'Prefer': 'respond-async, wait=1',
      'Content-Type': 'application/json',
      'Authorization':  'token ' + auth_token
    }

    response = requests.request("DELETE", url, headers = headers, data = payload)

    print(job_id, response.text, response.status_code)
0x085fd0a65058920c {"error":{"message":"Job is not in progress and cannot be cancelled.  Details: report template: TickHistoryIntradaySummaries"}} 400
0x085fd1335fd8929f {"error":{"message":"Job is not in progress and cannot be cancelled.  Details: report template: TickHistoryIntradaySummaries"}} 400
0x085fd1335f68929f {"error":{"message":"Job is not in progress and cannot be cancelled.  Details: report template: TickHistoryIntradaySummaries"}} 400
0x085fd0a64658920c {"error":{"message":"Job is not in progress and cannot be cancelled.  Details: report template: TickHistoryIntradaySummaries"}} 400

However, it says that the jobs aren't in progress which from the screenshot I posted is not true. I just want to get rid of these jobs as they eat into my processing capacity. Can you please help?

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.