Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

dns api call

Hello ,

           can anyone help me out in designate api call , i am following the documentation "https://designate.readthedocs.org/en/latest/rest/v1/domains.html#create-domain"

Here is my code

  $url = "mywebsite.com";
  $tokenid = "12313wqw121212121";

  $url_send='http://'.$url.':9001/v2/domains';
  $header1=  "X-Auth-Token:".$tokenid;
  $header2 = "Host: $url"; 
  $header3 = "Accept: application/json";
  $header4 = "Content-Type: application/json";

  $post='{
        "name": "domain1.com",
        "ttl": 3600,
        "email": "test@gmail.com"
    }';  

             $curl = curl_init();
     curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
     curl_setopt($curl, CURLOPT_POST, true);
     curl_setopt($curl, CURLOPT_URL, $url_send);
     curl_setopt($curl, CURLOPT_HTTPHEADER,array($header1,$header2,$header3,$header4));
     curl_setopt($curl, CURLOPT_HEADER, false);
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($curl, CURLOPT_POSTFIELDS, $post);

     $response = curl_exec($curl);
     curl_close($curl);

The result i am getting here is "Authentication required " . Here i am passing the token-id for authentication bt still its throwing the Authentication error .Can anyone please suggest me where i am going wrong .

Regards , Lokesh.S