Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

What is the syntax for "params" ? #28

Closed
hach3 opened this issue Aug 25, 2017 · 5 comments
Closed

What is the syntax for "params" ? #28

hach3 opened this issue Aug 25, 2017 · 5 comments

Comments

@hach3
Copy link

hach3 commented Aug 25, 2017

Hello there ! Thanks for the creation of this api tool. I wan't to create a dnsRecord but I don't understand how to write the params. Can i eventually get an example ? Thanks for answer ! <3

@hach3
Copy link
Author

hach3 commented Aug 25, 2017

#3

@hach3
Copy link
Author

hach3 commented Aug 25, 2017

I finally chose to call a childProcess which is a npm package (child_process) and use directly the curl version from the cloudflare documentation, looks like :

childProcess('curl -X POST "https://api.cloudflare.com/client/v4/zones/:zone_record/dns_records" -H "X-Auth-Email: XXXX@XX.fr" -H "X-Auth-Key: XXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -H "Content-Type: application/json" --data \'{"type":"CNAME","name":"' + username + '.ilikestream.com","content":"ilikestream.com","ttl":120,"proxied":true}\'', function(error, stdout, stderr) { console.log(error); });

@terinjokes
Copy link
Contributor

terinjokes commented Aug 25, 2017

@hach3 "params" is the JSON object required by the API, which you can see an example of in the documentation. In this case.

cf.dnsRecords.add({
  type: 'CNAME',
  name: username + '.ilikestream.com',
  content: 'ilikestream.com'.
  ttl: 120,
  proxied: true
});

There's definitely room for improvement to the node binding's documentation.

@kedoska
Copy link

kedoska commented Jul 21, 2018

using version 2.4.1

Response code 400 (Bad Request) 💥

    let resp = await cf.dnsRecords.add('SOME_ZONE_ID', {
      type: 'CNAME',
      name: 'some.domain.ext',
      content: '1.1.1.1', 
      proxied: true,
    })

However, the same zone and credentials works with other methods like cf.dnsRecords.browse.
@terinjokes in your example above you are not specifying the zone. Is that possible (to omit the zone id)?

@terinjokes
Copy link
Contributor

terinjokes commented Jul 21, 2018

No, zone ID is required for DNS operations, my example above is wrong.

It looks like you really want to set an A record, not a CNAME.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants