Ask Your Question
0

dns api call

asked 2014-04-24 01:57:04 -0500

Lokesh gravatar image

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

edit retag flag offensive close merge delete

Comments

Can you successfully use the same token to make a request against another openstack service? Does designate provide any additional information in its server logs?

larsks gravatar imagelarsks ( 2014-04-25 13:46:30 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2014-05-23 08:18:47 -0500

grahamhayes gravatar image

You are using the wrong version of the API.

In v1 - domains are called domains

(eg $url:$port/v1/domains )

In v2 they are zones

(eg $url:$port/v2/zones )

also, your post data is wrong, the domain needs the trailing . at the end like

$post='{
    "name": "domain1.com.",
    "ttl": 3600,
    "email": "test@gmail.com"
}';
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower

Stats

Asked: 2014-04-24 01:57:04 -0500

Seen: 164 times

Last updated: May 23 '14