Coder Social home page Coder Social logo

Comments (4)

leshik avatar leshik commented on August 12, 2024 1

I investigated further using curl and CF API documentation & examples. Previously, it was working like this (and that's how the documentation tells us to add DNS records):

curl -X POST "https://api.cloudflare.com/client/v4/zones/023e105f4ecef8ad9ca31a8372d0c353/dns_records" \
     -H "X-Auth-Email: [email protected]" \
     -H "X-Auth-Key: c2547eb745079dac9320b638f5e225cf483cc5cfdda41" \
     -H "Content-Type: application/json" \
     --data '{"type":"SRV","name":"_test._tcp.example.org","content":"0 0 1234 server.example.org"}'

This is not the case anymore. The API will return the error:

{
  "success": false,
  "errors": [
    {
      "code": 1004,
      "message": "DNS Validation Error",
      "error_chain": [
        {
          "code": 9101,
          "message": "service is a required data field."
        }
      ]
    }
  ],
  "messages": [],
  "result": null
}

Seems now there should be an additional data field inside the JSON, i.e.:

curl -X POST "https://api.cloudflare.com/client/v4/zones/023e105f4ecef8ad9ca31a8372d0c353/dns_records" \
     -H "X-Auth-Email: [email protected]" \
     -H "X-Auth-Key: c2547eb745079dac9320b638f5e225cf483cc5cfdda41" \
     -H "Content-Type: application/json" \
     --data '{"type":"SRV","name":"_test._tcp.example.org","content":"0 0 1234 server.example.org","data":{"priority":0,"weight":0,"port":1234,"target":"server.example.org","service":"_test","proto":"_tcp","name":"example.org"}}'

This works well, though not documented. Seems this should be changed in cfcli tool too.

from cloudflare-cli.

leshik avatar leshik commented on August 12, 2024

This JSON might look a bit redundant, I tested and it seems we can avoid duplication by removing name and content fields:

{
  "type": "SRV",
  "data": {
    "service": "_test",
    "proto": "_tcp",
    "name": "example.org",
    "priority": 0,
    "weight": 0,
    "port": 1234,
    "target": "server.example.org"
  }
}

It works ok too.

from cloudflare-cli.

leshik avatar leshik commented on August 12, 2024

Turned out, priority, weight and port can't be of type String anymore. I've made PR #47 that fixes it.

from cloudflare-cli.

leshik avatar leshik commented on August 12, 2024

I've also fixed priority parsing, it should be at index 0. In master it always equals to weight.

from cloudflare-cli.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.