Setting a Route's worker script to "None" via API

I have no issue setting a Routes worker to an actual script but attempting to set a routes working to “None” via the API.

curl -X PUT "https://api.cloudflare.com/client/v4/zones/0123456789/workers/routes/987654321cc3dac" \
     -H "X-Auth-Email: [email protected]" \
     -H "X-Auth-Key: 024681012141618202224262830" \
     -H "Content-Type: application/json" \
     --data '{"pattern":"someurl.com/*","script":"None"}'

I get the following message

{
  "result": null,
  "success": false,
  "errors": [
    {
      "code": 10019,
      "message": "workers.api.error.invalid_route_script_missing"
    }
  ],
  "messages": []
}

Is this by design or is there something else that represents “None”

How about an empty set of quotes?

Looking at the Audit Log, when I set to None, there’s just no line for the worker name. When I pick a worker, there’s a line that lists the name or the worker.

So maybe just leaving out

will do it.

I Tried this
Documentation says the following.

Name of the script to apply when the route is matched. The route is skipped when this is blank/missing.

{
  "result": null,
  "success": false,
  "errors": [
    {
      "code": 10019,
      "message": "workers.api.error.invalid_route_script_missing"
    }
  ],
  "messages": []
}

Is the message that is returned

I also tried removing the name of the script and quotes altogether and got the following

{
  "result": null,
  "success": false,
  "errors": [
    {
      "code": 10026,
      "message": "workers.api.error.parse_body"
    }
  ],
  "messages": []
}

Now I’m curious. I’m going to ask @1blas about this. Maybe he knows what syntax the Dashboard is sending.

1 Like

Great thought! If you can do it via the UI, I would imagine that there has to be a way to do the same via the API.

Also, I noticed that when “None” is selected and saved in the UI the message next to the route reads “Workers are disabled on this route” so maybe there is an option to just disabled the route.

Hey there @apowell4,

Out of curiosity, can you try using /filters instead of /routes in the API call?

Cheers,

1 Like

That did it!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.