0

I was able to run the API from the duncio Curl. Then try from google Apps Script. Part of Get the token WORKED, but then I can not make any more acion. I put the code in case it helps show where I have the problem

function Token() {
var user = "USUARIO";
var apikey= "KEY";
var Url = "https://identity.api.rackspacecloud.com/v2.0/tokens";
var payload =  {"auth":{"RAX-KSKEY:apiKeyCredentials":{"username": "mvillani","apiKey": apikey}}};   
var opt = {
                   "contentType" : "application/json",
                   "method" : "POST",
                   "payload" : Utilities.jsonStringify(payload)
                    };

var response = UrlFetchApp.fetch(Url,opt);
var json = JSON.parse(response.getContentText());
var token=json.access.token.id
var user="NUMERO DE USUARIO"                  

var Url="https://dns.api.rackspacecloud.com/v1.0/829221/domains/3715127/clone?cloneName=mvilaclone3.com" ;

var opt = {
                   "Content-Type": "application/json",
                   "method" : "POST",
                   "X-Auth-Token": token,
                   "Accept": "application/json"
                    };
  var response1 = UrlFetchApp.fetch(Url);
var json1 =response1.getContentText();
var c=2
}

Muchas Gracias !!!!

StephenTG
  • 2,579
  • 6
  • 26
  • 36
Mvillani
  • 11
  • 3
  • Can you tell what error you are seeing ? Also some link to the documentation of rackspace might help – Srik Aug 12 '13 at 15:54
  • Check out the following, it might help you: [addOAuthService(serviceName)](https://developers.google.com/apps-script/reference/url-fetch/url-fetch-app#addOAuthService(String)). Here a concrete example connecting to Twitter: [Twitter Approval Manager](https://developers.google.com/apps-script/articles/twitter_tutorial) – wchiquito Aug 12 '13 at 16:03
  • The function to get the token WORK. I can authenticate me. – Mvillani Aug 12 '13 at 16:56
  • curl-i-d \-H 'X-Auth-Token: d20c977b97bf43e8b8ffde255a48af81' \-H 'Accept: application / json' \ 'https://dns.api.rackspacecloud.com/v1.0/829221/domains/3715127 / clon? cloneName = mvdclone1.com ' – Mvillani Aug 12 '13 at 16:56

1 Answers1

0

I found the solution:

var Url="https://dns.api.rackspacecloud.com/v1.0/829221/domains/" ;
var response1 = UrlFetchApp.fetch(Url, {  "headers": {    'X-Auth-Token': Token  }})
Mogsdad
  • 44,709
  • 21
  • 151
  • 275
Mvillani
  • 11
  • 3