phpdnscloudflaremx-record

cloudflare-sdk : Can not Add MX record via API


I can not add the MX record in a Zone from the API. I’m using PHP sdk with this statement

$dns->addRecord(‘a07e52c68721e…’, ‘MX’, ‘@’, ‘mxa.mailgun.org’, 0, false, ‘10’)

And as a result (incomplete by the way)

GuzzleHttp/Exception/ClientException with message 'Client error: `POST https://api.cloudflare.com/client/v4/zones/a07e52c68721e.../dns_records` resulted in a `400 Bad Request` response:
{"success":false,"errors":[{"code":1004,"message":"DNS Validation Error","error_chain":[{"code":9104,"message":"priority  (truncated...)

I already read Issue 41 and I use cloudflare-php 1.1.0

Any help is welcome


Solution

  • This was obviously due to the argument ttd which had as default value 0 ... I put exactly 0 while the appropriate argument should be between 120 and 2147483647 according to the official documentation. So, it's this code that worked as @Patrick Mevzek

    $dns->addRecord(‘a07e52c68721e…’, ‘MX’, ‘@’, ‘mxa.mailgun.org’, 120, false, ‘10’)