Cannot create DNS record via HTTP API

I am pretty sure the response {"error":"undefined method end_with?’ for nil:NilClass"}` is a bug. Where do you report bugs in the API itself? (Details below)

curl -H 'Authorization: Bearer deadbeef' \
     --data \
     '{"type":"A",
       "hostname":"junk.example.net",
       "value":"192.168.0.1",
       "ttl":3600,
       "priority":null,
       "weight":null,
       "port":null,
       "flag":null,
       "tag":null}' \
     https://api.netlify.com/api/v1/dns_zones/feedbeef/dns_records/

responds with {"error":"undefined method end_with?’ for nil:NilClass"}`

Hey @aidalgol,
You’re welcome to file something here:

That said, our documented API is less up-to-date than our UI, so we usually advise that people view network requests from our UI in order to figure out what calls to make. The data that’s sent in the request from the UI when making an A record is:

  • hostname
  • ttl
  • type
  • value

so you may want to give that a shot.

1 Like

Thanks, I’ve just tried the same request but with only those fields in the JSON object, and even in the order you listed, and I still get the exact same response, but I did eventually get it working by explicitly setting Content-Type header needs to be explicitly set by adding the option -H 'Content-Type: application/json'. (I also raised this on the GitHub issue tracker you linked.)

Thank you, much appreciated!

1 Like