dns_txt_update API error

Discussion in 'ISPConfig 3 Priority Support' started by variable99, Feb 2, 2024.

  1. variable99

    variable99 Member HowtoForge Supporter

    Spent 4 hours debugging possible problem with API call 'dns_txt_update'. Here is my query:

    PHP:
    try {
       
    //* Parameters
       
    $id 12;
       
    $client_id 1;

       
    //* Get the dns record
       
    $dns_record $client->dns_txt_get($session_id$id);

       
    //* Change active to inactive
    $dns_record['name'] = $dkim['dns_hostname'];
     
    $dns_record['data'] = $dkim['dns_text'];

       
    $affected_rows $client->dns_txt_update($session_id$client_id$id$dns_record);

       echo 
    "Number of records that have been changed in the database: ".$affected_rows."<br>";

       if(
    $client->logout($session_id)) {
           echo 
    'Logged out.<br />';
       }
    } catch (
    SoapFault $e) {
       echo 
    $client->__getLastResponse();
       die(
    'SOAP Error: '.$e->getMessage());
    }
    $dns_record variable contains this:

    PHP:
    Array
    (
       [
    id] => 2735
       
    [sys_userid] => 1
       
    [sys_groupid] => 1
       
    [sys_perm_user] => riud
       
    [sys_perm_group] => riud
       
    [sys_perm_other] =>
       [
    server_id] => 6
       
    [zone] => 59
       
    [name] => default._domainkey.domain.tld.
       [
    type] => TXT
       
    [data] => v=DKIM1t=sp=MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEA3Bh5s1aCPI2HQhbsH54zBGAre2xRR5fPU26v0w7oQaTxBnQMp63tIOhXOs7YGfyuzd+d7h8DKhZrOccKg9HG48QdXYJINrZ6LUH2liCndiYs/krCA8/hA6D4bsnA7zxTTDn9pTz6fpitPvKRMgeze+Mtkr+c4hBOYFEe2cCgMCYEIa9pO4QvdRRolVbfSlQNWPC8XoPC3kZl/7v7azg5bEnIpOMH+KNw5NcOfyG/a1i8Ig3XYqYbafZ5nuMPktzFdbvvWmT3H3faGyC9gwj9m8+UOmG/J//2FdzRYgl1UIMAYwquXKsAa0hOUlbZdWTsFiU3H0q611mkZ07qgfda9YBxXkrU14oPaE8T4WFnLx3txByxX/s9FdPdP+OVlsdQZdmbJvkG18qtXfRfuX3mZaAJFmMAXHDSPqVNbn2mySkrLj1aScZMabAfgdCDuFo0XSnoNsmVauscsECQ1MZeAMHfeeed/P4/J+qRLvvbjLj6G9woHfyVL8QBviLDj5MDAgMBAAE=
       
    [aux] => 0
       
    [ttl] => 3601
       
    [active] => Y
       
    [stamp] => 2024-02-02 08:47:34
       
    [serial] => 2024020201
    )
    Error from API:

    PHP:
    Array
    (
       [
    error] => Array
           (
               [
    code] => data_processing_error
               
    [message] => data_error_empty
    ttl_range_error

           
    )

    )
    This is very frustrating. I debug every part of API call, it is according to the documentation and examples. What is wrong here?
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    You get two errors, the first one is:

    data_error_empty

    this means the data field is empty, you override the data field in the line:

    $dns_record['data'] = $dkim['dns_text'];

    so even if data might be filled in $dns_record before, it might be empty at that stage. And ttl must be > 60, otherwise the error ttl_range_error will get triggered. according to what you wrote, it is 3601, but nonetheless, this error is triggered, so it is likely empty or not > 60. I do not expect any issues with the API, as the migration tool uses it as well and the migration tool has no issues with importing DNS records.
     
    variable99 likes this.
  3. variable99

    variable99 Member HowtoForge Supporter

    You were correct. I missed client_id parameter in array. All is good.
     

Share This Page