Deploy/Publish worker via API

curl -s -X POST https://api.cloudflare.com/client/v4/accounts/my-account-id/workers/scripts/my-worker-name/subdomain -H "Authorization: Bearer my-token" -H "Content-Type:application/json" --data "{ enabled: true }"

{
  stdout: '{\n' +
    '  "result": null,\n' +
    '  "success": false,\n' +
    '  "errors": [\n' +
    '    {\n' +
    '      "code": 10026,\n' +
    '      "message": "workers.api.error.parse_body"\n' +
    '    }\n' +
    '  ],\n' +
    '  "messages": [x]\n' +
    '}\n',
  stderr: ''
}

Found !

You have to add quotes to enabled and double backslash

curl -s -X POST https://api.cloudflare.com/client/v4/accounts/my-account-id/workers/scripts/my-worker-name/subdomain -H "Authorization: Bearer my-token" -H "Content-Type:application/json" --data "{ \"enabled\": true }"

You can point directly to file too, if needed. using --data-binary "@dist/main.js"

1 Like

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