Non_field_error when creating RRset

Hi. When i created spf record. and i want to add dmarc record too. i try to use modifying an rrset but i take this error:

"non_field_errors": [
    "Expected a list of items but got dict."
]

i am using put method for https://desec.io/api/v1/domains/mydomain/rrsets/
(without subdomain)

and my request is:

"type": "TXT",

"records": ["\"v=spf1\"", "\"include:smtp.mydomain +a +mx ~all\"", "\"v=DMARC1\"", "\"p=none; sp=none; rua=mailto:my@mydomain; ruf=mailto::my@mydomain; rf=afrf; pct=100; ri=86400\"" ],

"ttl": 3600

Thanks.

Hi jjuglans,

Thanks for your message, and welcome to deSEC! <3

It looks like your request payload is structured like {"type": "TXT", ...}. However, the payload for PUT rrsets/ is required to be a list, so it should be structured like [{"type": "TXT", ...}]. (Note the surrounding square brackets.)

Hope that helps!

Stay secure,
Peter

Thank you very much. I edited my json request and worked:

[ {
    "subname": "_dmarc",
    "type": "TXT",
    "records": [
        "\"v=spf1 include:smtp.mydomain +a +mx ~all\"",
        "\"v=DMARC1; p=none; sp=none; rua=mailto:my@mydomain; ruf=mailto:my@mydomain\""
    ],
    "ttl": 3600
}]

And need

subdomain

parameter too. :slight_smile:

I am using postman for api calls.

I controlled now and SPF record and DMARC record must be entered separately as TXT record.

API calls to Desec.io for healthy and accurate DNS records:

Modifying an rrset SPF record with json request to https://desec.io/api/v1/domains/mydomain/rrsets/ with PUT method:

[{
    "subname": "",
    "type": "TXT",
    "records": ["\"v=spf1 a mx a:mydomain.tld ip4:mydomain_IP -all\""],
    "ttl": 3600
}]

Modifying an rrset DMARC record with json request https://desec.io/api/v1/domains/mydomain/rrsets/ with PUT method:

[{
    "subname": "_dmarc",
    "type": "TXT",
    "records": ["\"v=DMARC1; p=none; pct=100; rua=mailto:my@mydomain.tld; sp=none; aspf=r;\""],
    "ttl": 3600
}]

Modifying an rrset DKIM record with json request https://desec.io/api/v1/domains/mydomain/rrsets/ with PUT method:
(first you need to enable DKIM on your server and generate key)

[{
    "subname": "default._domainkey",
    "type": "TXT",
    "records": ["\"v=DKIM1; k=rsa; p=GENERATED_KEY_HERE\""],
    "ttl": 3600
}]