Turning on/off proxy for a domain thru the API

Hi All, nice to be in this community !!
I have 2 questions:
Straight to the point:

1-
I need to set proxy “off” for a recenty created “A Record” for a domain , issue some commands and then set it to “on” , all programatically done thru the API.
Now, when I first create the “A” record with the proyx off this way. all goes ok as expected:
curl -X POST … --data '{“type”:“A”,“name”:“domain1”, “content”:“nnn.nnn.nnn.nnn”,“ttl”:120,“priority”:10,“proxied”:false}
Record is created ok

After a few lines I need to set it to “true” so I issue:
curl -X PUT … --data '{“type”:“A”,“name”:“domain1”, “content”:“nnn.nnn.nnn.nnn”,“ttl”:120,“priority”:10,“proxied”:true}
what is giving us: “code”: 1001
“error”: “method_not_allowed”
although this request is valid as I can see in the API documentation:
https://api.cloudflare.com/#dns-records-for-a-zone-update-dns-record

what I’m doing wrong?

2- We are able to access the domain WITHOUT the “www” (ie. myname.domain.com) but we cannot access the www.myname.domain.com, even when we see the A Record successfully created…
Someone can suggest some clues to find why is not accesed with the “www”??

Thanks in Advance,
Robert

I am surprised by the error message as PUT is clearly allowed. My assumption would be your URL is not properly structured but because you left it out it’s impossible to say of course.

PATCH might be actually easier for your use case → Cloudflare API v4 Documentation

Depends on whether you get a DNS or SSL error. In the former case you’ll simply not have configured the necessary record. In the latter case you won’t have the necessary certificate (assuming you are proxying) → Subdomain too deep

user5615: Thansk for your fast reply!.

1-
curl -X PUT xxxxxxxxdns-records/ -H ‘X-Auth-Email: [email protected]’ -H ‘X-Auth-Key: nnnnnnnnnnnnn’ -H ‘Content-Type: application/json’ --data
'{“type”:“A”,“name”:“mycompanyc","content”:“nnn.nnn.nnn.nnn”,“ttl”:120,“priority”:10,“proxied”:true}
(this structure is the same used to create the off-proxy record and works ok)

I also have tried (a few minutes ago) with PATCH Method, giving the same
"code: 1001, “error”:
“method_not_allowed”…

(sorry not URL left out intentionally but honestly I don’t know how to copy/paste from a putty text console screen from our server so I need to copy it manually…)

Is there any list with error codes, symptons and fixes anywere ?

I end doing it manually, now just in the TEST environment…can’t be done this way in PRODUCTION…and we need urgently…

2- BOTH A Records (for mydomain and for www.mydomain are correctly set into Clouflare, corrects IP’S)…
what we receive when we try with the “www” is:

This site can’t provide a secure connection

“www.xxxxxx” uses an unsupported protocol.
ERR_SSL_VERSION_OR_CIPHER_MISMATCH

Worth to mention, I have tried 2 things:

1- generated a Self-Certificate only for mydomain and put a redirect to www into the Apache Conf file.
Didn’t work, same error…

2- generated A Self-Certificate for both (www.mydomain.net and mydomain.net)…left the redirect to www into Apache Conf file…same error.

3- access for mydomain.net works perfectly giving grade “B” in sslabs. access for www.mydomain.net gives us a : “Failed to communicate with the secure server”…

Any clue would be really appreciate it…
Thanks in Advance,
Robert

This is most certainly missing the required identifier. I’d refer you back to the documentation for the details.

So SSL error, in that case, see my earlier response as well.

1- Nop, is not missing the identifier …I need to put xxxx there because this site being a new user doesn’t enable me to put more than 4 urls (I don’t know why) but as I have mentioned before, the same request was working for create the first A record (in fact its a copy/paste with “false” change to “true” and PUT or PATCH).
Try your self to “unprox” any domain thru PUT and PATCH and you will the see the same error code… (with PUT or PATCH ) is the same…

2- So what is the suggestion taking in account the test I have already done ?

Thanks in advance,
Robert

From what you posted it appears to be missing. Post a screenshot of what you actually send and redact the credentials.

Not sure what you are saying, but I addressed the SSL issue in my first response.

Thanks Sandro.
Someone that can send a PUT or PATCH request to change the proxy status from off to on and vice-versa? so we can see the reply…
I cannot make it work…
Thanks in Advance,
Robert

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

Hi All, nice to be in this community !!
I have 2 questions:
Straight to the point:

1-
I need to set proxy “off” for a recenty created “A Record” for a domain , issue some commands and then set it to “on” , all programatically done thru the API.
Now, when I first create the “A” record with the proyx off this way. all goes ok as expected:
curl -X POST … --data '{“type”:“A”,“name”:“domain1”, “content”:“nnn.nnn.nnn.nnn”,“ttl”:120,“priority”:10,“proxied”:false}
Record is created ok

After a few lines I need to set it to “true” so I issue:
curl -X PUT … --data '{“type”:“A”,“name”:“domain1”, “content”:“nnn.nnn.nnn.nnn”,“ttl”:120,“priority”:10,“proxied”:true}
what is giving us: “code”: 1001
“error”: “method_not_allowed”
although this request is valid as I can see in the API documentation:
https://api.cloudflare.com/#dns-records-for-a-zone-update-dns-record

what I’m doing wrong?

Can someone please share the same request to we can see whats wrong with it?
Same structure and format is used to create the “A” record with proxy to “false” without any problem at all…
Thanks in Advance,
Robert

As per Cloudflare API v4 Documentation, you’re missing the identifier for the A record you created

PATCH zones/:zone_identifier/dns_records/:identifier

in the example on API docs, identifier for the DNS record is 372e67954025e0ba6aaa6d586b9e0b59 which is the created DNS record’s result ID when you query the DNS record via the API. Not to mistake that for zone_identifier (023e105f4ecef8ad9ca31a8372d0c353) in below example which is different

curl -X PATCH "https://api.cloudflare.com/client/v4/zones/023e105f4ecef8ad9ca31a8372d0c353/dns_records/372e67954025e0ba6aaa6d586b9e0b59" \
     -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":3600,"proxied":false}'
2 Likes

That screenshot shows the same missing identifier I mentioned two weeks ago and which @eva2000 now pointed out as well.

I can only repeat what I wrote back then.

2 Likes

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