Post API Create DNS Record issue noob

Hello i’m trying to create dns zone via Api post request and i’m getting this error :

{“success”:false,“errors”:[{“code”:7003,“message”:“Could not route to /zones/:0d43890c5f6f72e3abb66d094016ca2c/f36443603930374c34ee1b7109dd4fa0, perhaps your object identifier is invalid?”},{“code”:7000,“message”:“No route for that URI”}],“messages”:,“result”:null}

this is the post request i’m doing

i edited my ids above

The Zone-Identifier at your script is starting with a colon. I think the colon is wrong.

Please have a read here:

1 Like

i did check the documentation thanks fixed it but now it is showing

HTTP/1.1 400 Bad Request
Date: Tue, 12 Jan 2021 14:40:53 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive
CF-Ray: 6107a29d6a9f2d73-KBP
CF-Cache-Status: DYNAMIC
cf-request-id: 0798a3f65d00002d730b07f000000001
Expect-CT: max-age=604800, report-uri=“https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct
Vary: Accept-Encoding
Server: cloudflare

{“success”:false,“errors”:[{“code”:9106,“message”:“Missing X-Auth-Key, X-Auth-Email or Authorization headers”}]}

i have tried with both api Token i created and Global API Key same result .

I dont know how you exactly implemented this, but could you try to test it with a script and see if it works with it?
As I really dont know with which programm you run this.

Just run this and replace the current data with your own ones:

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":"A","name":"example.com","content":"127.0.0.1","ttl":120,"priority":10,"proxied":false}'

Short:

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":"A","name":"example.com","content":"127.0.0.1","ttl":120,"priority":10,"proxied":false}'

Maybe you have to excape the all " in --data with \" like this:

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\":\"A\",\"name\":\"example.com\",\"content\":\"127.0.0.1\",\"ttl\":120,\"priority\":10,\"proxied\":false}'

Short:

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\":\"A\",\"name\":\"example.com\",\"content\":\"127.0.0.1\",\"ttl\":120,\"priority\":10,\"proxied\":false}'

Also I would try to run it with:

-H "Authorization: Bearer $auth_key" (you need to create a token for this)

instead of:

-H "X-Auth-Email: $auth_email"

1 Like

Thank you so much for help i tried a little different from the soft i use and it worked perfectly though had to use global api !

Here is the solution that worked for me with zennoposter
https://zennolab.com/discussion/threads/how-can-i-use-cloudflare-api-to-create-dns-records-on-auto.87684/

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.