Jordi
Jordi

Reputation: 23277

Shell Script: curl malformed body

I'm getting this error message:

json parse error: invalid character 'E' after top-level value (202020207b202020202020226b696e64223a2022536563726574222c2020 ...)

I'm launching a curl statement from my shell script:

curl -k \
    -X PUT \
    -d @- \
    -H "Authorization: Bearer $TOKEN" \
    -H "Accept: application/json" \
    -H "Content-Type: application/json" \
    "$SERVER_URL/api/v1/namespaces/$NAMESPACE/secrets/t-secret" <<'EOF'
    {
      "kind": "Secret",
      "apiVersion": "v1",
      "data": {
        "rabbit-password": "fromcontainer"
      }
    }
    EOF

Any ideas?

Upvotes: 0

Views: 199

Answers (1)

chepner
chepner

Reputation: 532153

You cannot indent the closing EOF with spaces.

curl -k \
    -X PUT \
    -d @- \
    -H "Authorization: Bearer $TOKEN" \
    -H "Accept: application/json" \
    -H "Content-Type: application/json" \
    "$SERVER_URL/api/v1/namespaces/$NAMESPACE/secrets/t-secret" <<'EOF'
    {
      "kind": "Secret",
      "apiVersion": "v1",
      "data": {
        "rabbit-password": "fromcontainer"
      }
    }
EOF

Upvotes: 1

Related Questions