diff --git a/manage-dns.pl b/manage-dns.pl index 0f84df2..57c7719 100755 --- a/manage-dns.pl +++ b/manage-dns.pl @@ -209,13 +209,13 @@ sub check_and_update_record($$$$$) { # Update the record $record->{ttl} = $in->[0]->{defaults}->{ttl}->{$zone}; _debug("Will update ", $url, $record, to_json($record)); - push(@to_update, $record); + push(@to_update, [$url,$record]); } } else { # Create new record my $new = format_record($zone, $type, $host, $value); _notice("Will create new record: %s %s %s", $host, $type, $value); - push(@to_create, $new); + push(@to_create, [$url,$new]); } } @@ -297,10 +297,10 @@ unless($DRY_RUN) { # Create foreach my $record (@to_create) { my $res = $ua->post( - $url, + $record[0], "Content-Type" => "application/json", Content => to_json({ - records => [ $record ] + records => [ $record[1] ] }) ); warn "Failed to create $url: " . $res->status_line . "\n" . $res->content unless $res->is_success; @@ -309,9 +309,9 @@ unless($DRY_RUN) { # Update foreach my $record (@to_update) { my $res = $ua->put( - $url, + $record[0], "Content-Type" => "application/json", - "Content" => to_json({ records => [ $record ] }), + "Content" => to_json({ records => [ $record[1] ] }), ); warn "Failed to update $url: " . $res->status_line unless $res->is_success; }