lexicon icon indicating copy to clipboard operation
lexicon copied to clipboard

Creating records on godaddy throws: 422 Client Error: Unprocessable Entity

Open mpfusion opened this issue 6 years ago • 5 comments

Attempts to create or delete DNS records using the following command

lexicon godaddy \
  --auth-key="$key" --auth-secret="$secret" \
  create "$domain" TXT \
  --name "foo.$domain" \
  --content "bar"

fails with

Traceback (most recent call last):
  File "/usr/local/bin/lexicon", line 11, in <module>
    load_entry_point('dns-lexicon==3.1.4', 'console_scripts', 'lexicon')()
  File "/usr/local/lib/python3.6/site-packages/lexicon/cli.py", line 117, in main
    results = client.execute()
  File "/usr/local/lib/python3.6/site-packages/lexicon/client.py", line 71, in execute
    return self.provider.create_record(record_type, name, content)
  File "/usr/local/lib/python3.6/site-packages/lexicon/providers/base.py", line 80, in create_record
    return self._create_record(rtype, name, content)
  File "/usr/local/lib/python3.6/site-packages/lexicon/providers/godaddy.py", line 115, in _create_record
    self._put('/domains/{0}/records'.format(domain), records)
  File "/usr/local/lib/python3.6/site-packages/lexicon/providers/base.py", line 148, in _put
    return self._request('PUT', url, data=data, query_params=query_params)
  File "/usr/local/lib/python3.6/site-packages/lexicon/providers/godaddy.py", line 269, in _request
    result.raise_for_status()
  File "/usr/local/lib/python3.6/site-packages/requests/models.py", line 940, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 422 Client Error: Unprocessable Entity for url: https://api.godaddy.com/v1/domains/example.com/records

The record is created, though. Optaining a list of records works without error:

lexicon godaddy list "$domain" TXT --auth-key="$key" --auth-secret="$secret"

Let me know if you need further information.

11.2-STABLE FreeBSD lexicon 3.1.4

mpfusion avatar Feb 09 '19 22:02 mpfusion

I'm getting a similar error on 3.1.5 for all operations (except once I was able to create a record, now running the same command produces and error - having deleted the entry manually).

lexicon godaddy --auth-key key --auth-secret secret create "domain.net" A --name="sub.domain.net" --content="1.1.1.111"

Traceback (most recent call last):
  File "/usr/local/bin/lexicon", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/lexicon/cli.py", line 117, in main
    results = client.execute()
  File "/usr/local/lib/python2.7/dist-packages/lexicon/client.py", line 71, in execute
    return self.provider.create_record(record_type, name, content)
  File "/usr/local/lib/python2.7/dist-packages/lexicon/providers/base.py", line 80, in create_record
    return self._create_record(rtype, name, content)
  File "/usr/local/lib/python2.7/dist-packages/lexicon/providers/godaddy.py", line 115, in _create_record
    self._put('/domains/{0}/records'.format(domain), records)
  File "/usr/local/lib/python2.7/dist-packages/lexicon/providers/base.py", line 148, in _put
    return self._request('PUT', url, data=data, query_params=query_params)
  File "/usr/local/lib/python2.7/dist-packages/lexicon/providers/godaddy.py", line 269, in _request
    result.raise_for_status()
  File "/usr/local/lib/python2.7/dist-packages/requests/models.py", line 935, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 422 Client Error: Unprocessable Entity for url: https://api.godaddy.com/v1/domains/mydomain.net/records

sebkouba avatar Mar 01 '19 12:03 sebkouba

I was getting 422 errors and went into Godaddy's API tools to test things out, for my domain that was giving me grief, I'm getting this error in my 422 response:

"At least two NS records must be specified in the request body"

After resolving all API validation errors. I'm really unsure how to resolve it (no mention of this in GoDaddy's docs) and my domain in question is using default nameservers from GoDaddy.

derekaug avatar Mar 13 '19 17:03 derekaug

I'm getting the same kind of issues when trying to create MX and SRV records on godaddy.

I'm suspecting that this is related to the fact that Godaddy's API expects a specific priority fields for MX and SRV records (+ other keys for SRV), c.f. https://developer.godaddy.com/doc/endpoint/domains#/v1/recordReplaceTypeName

(Also Lexicon's test suite doesn't seem to validate that MX / SRV record creation does work for each provider?)

alexAubin avatar Sep 14 '21 14:09 alexAubin

Just found out that, when there is a CNAME record for a subdomain, say for example, support.example.com to somesite.com, and you try to add an MX record for support.example.com to anything.com, I am seeing 422 unprocessable entity error.

gprasanth avatar Oct 08 '21 09:10 gprasanth

I was able to do it applying these changes https://github.com/AnalogJ/lexicon/pull/1834

GiviMAD avatar Dec 17 '23 15:12 GiviMAD