Apify and Crawlee Official Forum

Home
Members
Omar Abdelkader
O
Omar Abdelkader
Offline, last seen 4 months ago
Joined August 30, 2024
I am using the Apify JS client to update a task's inputs and options and am finding that it is not correctly honoring the API documentation

https://docs.apify.com/api/v2#/reference/actor-tasks/task-collection/update-task

In this doc, it says "If the object does not define a specific property, its value is not updated." However, in my testing, I have found that this is not the case. Rather, it will fail if any required variables are missing from the update patch. Even worse, options that aren't specified are removed entirely.

Take this example with the website content crawler actor. I can get the task information by its ID, but when I try to update just the "crawlerType", I get an error that "startUrls" is missing even though it clearly already exists on the task. Even more interestingly, the operation succeeds when I use the updateInput endpoint. Why is the behavior correctly following the documentation for updateInput but not update ?

https://gist.github.com/omikader/efe8c75eff27c36a4edeb782ddf59006
4 comments
o
O
We use the Apify JS client and started seeing some strange errors when programmatically creating new actor tasks. Here is the code we use to create a task

Plain Text
const task = await apifyClient.tasks().create({
  actId: "apify/website-content-crawler",
  options: { memoryMbytes: 4096, build: "version-0" },
  input: { ...BASE_TASK_INPUT, startUrls: [{ url }], maxCrawlDepth: depth },
});


As you can see we don't provide an argument for title or name and instead rely on the autogenerated value from Apify, e.g. website-content-crawler-task-2 website-content-crawler-task-3 ...

However, the error in the screenshot suggests that there is a name conflict. I suspect that this is happening because we are creating many tasks concurrently and the Apify server's internal counter collides when creating the new task.

  • Can someone confirm if this is the case?
  • Is it suggested that we provide own name to avoid issues like this in the future?
  • What is the valid format for a task name in Apify? (e.g. character limit, valid character set, etc.)
  • How about task titles? Do they have any name restrictions?
Thank you!
3 comments
P
O
S
I am using the API JS client version 2.8.0 to programmatically create a schedule with 1 task action. The code looks like the following

Plain Text
const schedule = await client.schedules().create({
  isEnabled: true,
  cronExpression,
  actions: [
    {
      type: ScheduleActions.RunActorTask,
      actorTaskId: task.id,
    },
  ],
});


However, I get a TS error saying that my action object is missing an id field due to the following interface definition:

Plain Text
interface BaseScheduleAction<Type extends ScheduleActions> {
    id: string;
    type: Type;
}


When I try to supply a value, the operation fails and no task is added but it works when I add a // @ts-ignore statement and omit id entirely. I suspect that the interface definition is incorrect and id should not be required and instead should be generated by Apify. My suspicions are further confirmed by the fact that the network request sent from the client does not include a value for id when adding a task to a schedule in the UI (see attached image)
4 comments
L
O
A
Hello, I am interested in setting a webhook to receive events when a particular actor run has succeeded. However, I want to be able to secure my endpoint to ensure that only Apify can invoke it.

I found an earlier post from June suggesting that this isn't possible but the Apify documentation suggests otherwise:
https://discord.com/channels/801163717915574323/1115873908046966864

The documentation says to do the following:
https://docs.apify.com/platform/integrations/webhooks/actions
Plain Text
For safety reasons, the webhook URL should contain a secret token to ensure only Apify can invoke it.


However, I am unsure of what this means. Does anyone have any advice? For additional context, I am using AWS API Gateway.
4 comments
O
P
L