How can I upload a script to Cloudflare Workers from the command line?

I have been trying and failing to get a script onto Cloudflare Workers using the command line. As a test I tried sending this simple JSON. But it complains about content type when as far as I can tell I am sending a perfectly valid JSON. Is there something wrong with how I am doing this (or is it possible?)

-> % read -r -d '' js <<EOF
{"foo" : "bar"}

-> % echo "$js" | jq

  "foo": "bar"

-> % curl -s -X PUT "$acc_id/workers/scripts/foobar" \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer $CLOUDFLARE_WORKER_TOKEN" \
  --data "$json"
  "result": null,
  "success": false,
  "errors": [
      "code": 10001,
      "message": "workers.api.error.content_type"
  "messages": []