abacao
abacao
CDCloudflare Developers
Created by abacao on 3/23/2025 in #general-help
DNS Update records with CURL
I have found the documentation on Cloudflare assets a bit behind or confusing
38 replies
CDCloudflare Developers
Created by abacao on 3/23/2025 in #general-help
DNS Update records with CURL
thanks for both your help @Chaika @Cyb3r-Jok3
38 replies
CDCloudflare Developers
Created by abacao on 3/23/2025 in #general-help
DNS Update records with CURL
Shouldn't the documentation in here (https://developers.cloudflare.com/api/resources/dns/subresources/records/methods/edit/) be updated just to have the Authorizaton bearer header?
38 replies
CDCloudflare Developers
Created by abacao on 3/23/2025 in #general-help
DNS Update records with CURL
the only thing that didnt was the name
38 replies
CDCloudflare Developers
Created by abacao on 3/23/2025 in #general-help
DNS Update records with CURL
No description
38 replies
CDCloudflare Developers
Created by abacao on 3/23/2025 in #general-help
DNS Update records with CURL
the documentation in here: https://developers.cloudflare.com/api/resources/dns/subresources/records/methods/edit/ says
curl https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records/$DNS_RECORD_ID \
-X PATCH \
-H 'Content-Type: application/json' \
-H "X-Auth-Email: $CLOUDFLARE_EMAIL" \
-H "X-Auth-Key: $CLOUDFLARE_API_KEY" \
-d '{
"comment": "Domain verification record",
"content": "198.51.100.4",
"name": "example.com",
"proxied": true,
"ttl": 3600,
"type": "A"
}'
curl https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records/$DNS_RECORD_ID \
-X PATCH \
-H 'Content-Type: application/json' \
-H "X-Auth-Email: $CLOUDFLARE_EMAIL" \
-H "X-Auth-Key: $CLOUDFLARE_API_KEY" \
-d '{
"comment": "Domain verification record",
"content": "198.51.100.4",
"name": "example.com",
"proxied": true,
"ttl": 3600,
"type": "A"
}'
38 replies
CDCloudflare Developers
Created by abacao on 3/23/2025 in #general-help
DNS Update records with CURL
{"result":null,"success":false,"errors":[{"code":9207,"message":"Request body is invalid."}],"messages":[]}%
38 replies
CDCloudflare Developers
Created by abacao on 3/23/2025 in #general-help
DNS Update records with CURL
No description
38 replies
CDCloudflare Developers
Created by abacao on 3/23/2025 in #general-help
DNS Update records with CURL
No description
38 replies
CDCloudflare Developers
Created by abacao on 3/23/2025 in #general-help
DNS Update records with CURL
is I use the same headers rather than the ones in the image
{"result":null,"success":false,"errors":[{"code":9207,"message":"Request body is invalid."}],"messages":[]}%
{"result":null,"success":false,"errors":[{"code":9207,"message":"Request body is invalid."}],"messages":[]}%
38 replies
CDCloudflare Developers
Created by abacao on 3/23/2025 in #general-help
DNS Update records with CURL
in the terminal, both values are CURLed from the API with the following headers
-H "Content-Type: application/json" \
-H "X-Auth-Email: $CLOUDFLARE_EMAIL" \
-H "Authorization: Bearer $CLOUDFLARE_API_KEY" \
-H "Content-Type: application/json" \
-H "X-Auth-Email: $CLOUDFLARE_EMAIL" \
-H "Authorization: Bearer $CLOUDFLARE_API_KEY" \
38 replies
CDCloudflare Developers
Created by abacao on 3/23/2025 in #general-help
DNS Update records with CURL
I'm going crazy
38 replies
CDCloudflare Developers
Created by abacao on 3/23/2025 in #general-help
DNS Update records with CURL
No description
38 replies
CDCloudflare Developers
Created by abacao on 3/23/2025 in #general-help
DNS Update records with CURL
curl -s \
-X PATCH "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records/$DNS_RECORD_ID" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $CLOUDFLARE_API_KEY" \
-d "{
"type:" "A",
"name:" "$DNS_RECORD_NAME",
"content:" "1.1.1.1",
"ttl:" "10",
"proxied:" "false"
}"
curl -s \
-X PATCH "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records/$DNS_RECORD_ID" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $CLOUDFLARE_API_KEY" \
-d "{
"type:" "A",
"name:" "$DNS_RECORD_NAME",
"content:" "1.1.1.1",
"ttl:" "10",
"proxied:" "false"
}"
like this? error: {"success":false,"errors":[{"code":10000,"message":"PATCH method not allowed for the api_token authentication scheme"}]}
38 replies
CDCloudflare Developers
Created by abacao on 3/23/2025 in #general-help
DNS Update records with CURL
when I run the update record:
curl -s \
-X PATCH "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records/$DNS_RECORD_ID" \
-H "Content-Type: application/json" \
-H "X-Auth-Email: $CLOUDFLARE_EMAIL" \
-H "Authorization: Bearer $CLOUDFLARE_API_KEY"
-d "{
"type:" "A",
"name:" "$DNS_RECORD_NAME",
"content:" "1.1.1.1",
"ttl:" "10",
"proxied:" "false"
}"
curl -s \
-X PATCH "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records/$DNS_RECORD_ID" \
-H "Content-Type: application/json" \
-H "X-Auth-Email: $CLOUDFLARE_EMAIL" \
-H "Authorization: Bearer $CLOUDFLARE_API_KEY"
-d "{
"type:" "A",
"name:" "$DNS_RECORD_NAME",
"content:" "1.1.1.1",
"ttl:" "10",
"proxied:" "false"
}"
{"success":false,"errors":[{"code":10000,"message":"PATCH method not allowed for the api_token authentication scheme"}]}
38 replies
CDCloudflare Developers
Created by abacao on 3/23/2025 in #general-help
DNS Update records with CURL
the dns record i want to update with this
curl -s \
-X GET "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records?type=A&name=$DNS_RECORD_NAME" \
-H "Content-Type: application/json" \
-H "X-Auth-Email: $CLOUDFLARE_EMAIL" \
-H "Authorization: Bearer $CLOUDFLARE_API_KEY" \
| jq .
curl -s \
-X GET "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records?type=A&name=$DNS_RECORD_NAME" \
-H "Content-Type: application/json" \
-H "X-Auth-Email: $CLOUDFLARE_EMAIL" \
-H "Authorization: Bearer $CLOUDFLARE_API_KEY" \
| jq .
38 replies
CDCloudflare Developers
Created by abacao on 3/23/2025 in #general-help
DNS Update records with CURL
I'm getting my zone in the overview page and by running this
curl -s \
-X GET "https://api.cloudflare.com/client/v4/zones?name=$ZONE_NAME&status=active" \
-H "Content-Type: application/json" \
-H "X-Auth-Email: $CLOUDFLARE_EMAIL" \
-H "Authorization: Bearer $CLOUDFLARE_API_KEY" \
| jq -r '{"result"}[] | .[0] | .id'
curl -s \
-X GET "https://api.cloudflare.com/client/v4/zones?name=$ZONE_NAME&status=active" \
-H "Content-Type: application/json" \
-H "X-Auth-Email: $CLOUDFLARE_EMAIL" \
-H "Authorization: Bearer $CLOUDFLARE_API_KEY" \
| jq -r '{"result"}[] | .[0] | .id'
38 replies
CDCloudflare Developers
Created by abacao on 3/23/2025 in #general-help
DNS Update records with CURL
I did... I can use the same information to other CURLS such as
38 replies
CDCloudflare Developers
Created by abacao on 3/23/2025 in #general-help
DNS Update records with CURL
I'm sorry but I've tested exactly that. There must be something wrong with my account. I have tried the API Token and the Global API key. Both deliver errors. I have recreated the tokens without any changes on the output of the commands
curl \
-X PATCH "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records/$DNS_RECORD_ID" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $CLOUDFLARE_API_KEY" \
-d "{
"type:" "A",
"name:" "$DNS_RECORD_NAME",
"content:" "1.1.1.1",
"ttl:" "10",
"proxied:" "false"
}"
curl \
-X PATCH "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records/$DNS_RECORD_ID" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $CLOUDFLARE_API_KEY" \
-d "{
"type:" "A",
"name:" "$DNS_RECORD_NAME",
"content:" "1.1.1.1",
"ttl:" "10",
"proxied:" "false"
}"
{"success":false,"errors":[{"code":10000,"message":"PATCH method not allowed for the api_token authentication scheme"}]}
curl \
-X PATCH "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records/$DNS_RECORD_ID" \
-H "Content-Type: application/json" \
-H "X-Auth-Email: $CLOUDFLARE_EMAIL" \
-H "X-Auth-Key: $CLOUDFLARE_API_KEY" \
-d "{
"type:" "A",
"name:" "$DNS_RECORD_NAME",
"content:" "1.1.1.1",
"ttl:" "10",
"proxied:" "false"
}"
curl \
-X PATCH "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records/$DNS_RECORD_ID" \
-H "Content-Type: application/json" \
-H "X-Auth-Email: $CLOUDFLARE_EMAIL" \
-H "X-Auth-Key: $CLOUDFLARE_API_KEY" \
-d "{
"type:" "A",
"name:" "$DNS_RECORD_NAME",
"content:" "1.1.1.1",
"ttl:" "10",
"proxied:" "false"
}"
{"success":false,"errors":[{"code":10001,"message":"Unable to authenticate request"}]}
38 replies
CDCloudflare Developers
Created by abacao on 3/23/2025 in #general-help
DNS Update records with CURL
@Cyb3r-Jok3 documentation states the need of auth-email and auth-key https://developers.cloudflare.com/api/resources/dns/subresources/records/methods/edit/
38 replies