List DNS Records Methode not work with SRV Record

Hallo,

I have a Problem with the List DNS Records Methode from the API.
I try to use the following curl command:

cf_get=$(curl -sX GET "${cf_api}zones/${cf_dns_zone}/dns_records?${options}" \
-H "Authorization: Bearer ${cf_api_key}" \
-H "Content-Type: application/json")

And the curl GET request work with A, TXT Records without any problems but when i try to search for a SRV Record i get a problem.

The $options Variable is this:

options="type=${type}&name=${hostname}&${data}"

And the $data Variable is:

data="data={\"service\":\"${service}\",\"proto\":\"${proto}\",\"name\":\"${domain}\",\"priority\":${priority},\"weight\":${weight},\"port\":${port},\"target\":\"${target}\"}"

This curl request also works but the API returns my not one result it returns seven times the same dns record.

How i can fix this problem ?
Is this a API Bug ?

Your call is not quite clear to me and does seem somewhat invalid
From what I understand you basically send this request

/dns_records?type=SRV&name=[whatever-name-you-specified]&data=[JSON-string]

For starters, data does not seem to be a valid field for this request, https://api.cloudflare.com/#dns-records-for-a-zone-list-dns-records, furthermore this request does not appear to take any JSON values in the first place.

What is it you want to achieve? If you want to fetch all SRV records for a given hostname simply filter by these two fields and you are good to go.

I will fetch only on SRV record with this request to get the id of the record

But this field work on this request. The structure for the data object is from how i can create a SRV record.
The field priority is also not in the docomentation but work to.

Then follow the approach I just mentioned.

It is not listed as valid field.

That is a different request.

Again, if you simply want to fetch the SRV record filter by that and you are good to go.

That is not a uniquent request it is possible to have the same hostname and type more times.
I need this request to get the uniquent id of the record.

Then either filter that on your side or use the content field to filter for the record’s value.

The content field not work on SRV records.

Of course there is. Post the hostname in question.

But again, https://api.cloudflare.com/#dns-records-for-a-zone-list-dns-records is the official documentation for that request which you need to stick to. It does not support a data field with JSON values I am afraid.

"name": "_test._tcp.example.com",
"type": "SRV",
"content": "0\t100\tapi.example.com",
"priority": 2,

This is the content field of a SRV record how i can send this Informations with a GET Request ?

You follow the example mentioned in the documentation. I am not sure what is unclear there, the fields are each described.

Try to fetch a SRV record after this you will understand why you can’t use content="api.example.com" this will not work.

Of course it won’t because you need to provide the content of the record and that content is not valid for an SRV record.

Again, what is the hostname?

The Hostname is _test._tcp.example.com

Doesn’t resolve :wink:

nslookup -type=srv _test._tcp.example.com 1.1.1.1
Server:  one.one.one.one
Address:  1.1.1.1

*** one.one.one.one can't find _test._tcp.example.com: Non-existent domain
1 Like

really that is a example hostname not a real hostname ^^

Well, I obviously asked for the actual hostname. An example hostname is not exactly helpful.

For what do you need my hostname you only need the API and a SRV Record to test / debug the problem. You can’t use your API on my Domain you need your own Domain for testing.

We are going in circles here.

All right, you need to follow https://api.cloudflare.com/#dns-records-for-a-zone-list-dns-records. That documentation outlines what is accepted and what not and you need to provide the data in the right format. data is not accepted.

Yes that is the problem the List DNS Records Methode from the API has no good implementation for SRV records that is right.

That is most likely not true and I already addressed that earlier.