For Workes & Pages, what is the name of the domain?
domain.tld
What is the error number?
9101
What is the error message?
DNS Validation Error
What is the issue or error you’re encountering
I can’t add SRV record
What steps have you taken to resolve the issue?
Wrote a simple script to add a SRV record. I got this error: Response: {“result”:null,“success”:false,“errors”:[{“code”:1004,“message”:“DNS Validation Error”,“error_chain”:[{“code”:9101,“message”:“weight is a required data field.”}]}],“messages”:}.
But if I add weight I get another error: Response: {“result”:null,“success”:false,“errors”:[{“code”:9207,“message”:“Request body is invalid.”}],“messages”:}
How to add SRV record using API or library cloudflare-go ?
What are the steps to reproduce the issue?
#!/bin/bash
API_TOKEN=“XXX”
ZONE_ID=“1234”
DOMAIN=“example.com”
SERVICE=“_service”
PROTO=“_tcp”
TARGET=“target.example.com”
PORT=1234
PRIORITY=10
WEIGHT=5
TTL=120
SRV_NAME=“${SERVICE}.${PROTO}.${DOMAIN}”
JSON_DATA=$(cat <<EOF
{
“type”: “SRV”,
“name”: “$SRV_NAME”,
“content”: “${PRIORITY} ${WEIGHT} ${PORT} ${TARGET}”,
“ttl”: $TTL,
“proxied”: false
}
EOF
)
RESPONSE=$(curl -s -X POST “https://api.cloudflare.com/client/v4/zones/${ZONE_ID}/dns_records”
-H “Authorization: Bearer ${API_TOKEN}”
-H “Content-Type: application/json”
–data “$JSON_DATA”)
if echo “$RESPONSE” | grep -q ‘“success”:true’; then
echo “SRV record created successfully”
else
echo “Error creating SRV record”
echo “Response: $RESPONSE”
fi