Starting a Task by Javascript

Does anyone know if it’s possible to start an Object’s task programmatically using Javascript?
Currently, only scheduled options are available but I need to do it on specific event, not cyclic period.

I dug deep into the Knack object and found task-related stuff but not sure how to use them.

Normand D.

Hello Normand,

Yes, you can do that but it explores your api keys.

Regards,
Sunny Singla

1 Like

Hey @Sunny_Singla keen to know the basic syntax if you can share something?

Sure Brad,

try the below code it works for me.

$.ajax({
url: ‘https://eu-central-1-renderer-read.knack.com/v1/applications/**APPLICATIONID**/tasks/task_1/runtaskjob’,
type: ‘GET’,
headers: {
‘X-Knack-Application-Id’: ‘APPID’, // change to your app’s API info
‘X-Knack-REST-API-Key’: ‘KEY’. // change to your app’s key
},
success: function (response) {

    }
});

you need to change task_1 with you task id

Thanks

1 Like

Sunny,

That’s pretty cool, thanks!

I’m very curious to know… where did you get that information?
Is there a full documentation of these functions somewhere?

Norm

Yep - same questions!
Tested and works BTW and could be obfuscated via a Make.com scenario.

Hello Normand,

There is no documentation for this.

Regards,
Sunny Singla

Ok but then, how did you find out about the URL and the runtaskjob command?
I wonder what else is hiding that could be useful…

Norm

I partially answered myself.

In the console view, I had an error on a PUT and saw this URL:
https://us-east-1-renderer-write.knack.com/v1/scenes/scene_xxx/views/view_yyy/records/

So I extracted the first part until the v1/ and tried this:
https://us-east-1-renderer-read.knack.com/v1/applications/APP_ID

Tadam! A ton of code appeared, and at the end, there were my server URLs:

    "clientSubdomainMap": {
      "read": [
        "us-east-1-renderer-read"
      ],
      "write": [
        "us-east-1-renderer-write"
      ]
    }

But that’s only a partial answer. What about the runtaskjob command?

Norm

Normand,

I also check this in the console. while running tasks manually.

Thanks,
Sunny