2017-07-12 5 views
2

私はAPIのURL呼び出しをやっているが、私はこのエラーここGoogleのスクリプト - APIを呼び出す - Errorオブジェクト

TypeError: Cannot find function getContentText in object

は私のコードを怒鳴るあるんです。 URLをエンコードしようとしましたが、まだ動作しませんでした。 私が間違っている場所を教えてください。そして、修正は何ですか?

が見つかっ

var url = 'https://welcome.de.coremetrics.com/analyticswebapp/api/1.0/report-data/explore/explore.ftlid=634022'; 
 
    var params = { 
 
    'clientId': 'mi_id', 
 
    'format': 'JSON', 
 
    'userAuthKey' : 'my_key', 
 
    'language' : 'en_US', 
 
    'viewID' : 'default.ftl', 
 
    'period_a' : 'D20170601', 
 
    'fileName' : 'explore_explore^id=634022_default_view_D20170601.json' 
 
    } 
 
    var options = { 
 
    'method' : 'GET', 
 
    'payload' : params 
 
}; 
 
    
 
    response = UrlFetchApp.getRequest(url,options); 
 
    var data = JSON.parse(response.getContentText());

+0

UrlFetchApp.getRequest() '' ''で、何の '' getContentText() ''はありません。あなたは ''応答 ''を直接見ることができます。したがって、 '' Logger.log(response) ''を使うことができます。 '' fetch''を実行したい場合は、 '' UrlFetchApp.getRequest() ''を '' UrlFetchApp.fetch() ''に変更してください。 '' UrlFetchApp.fetch() ''の場合、 '' getContentText() ''をレスポンスに使用できます。詳細情報はhttps://developers.google.com/apps-script/reference/url-fetch/url-fetch-app#methods – Tanaike

+0

ありがとうございます!できます ! – Bastien

+0

ようこそ。こちらこそありがとう。 – Tanaike

答えて

0

ソリューション、ありがとう:

res = encodeURI(query) 
    response = UrlFetchApp.fetch(res, {muteHttpExceptions: true, escaping: false}).getContentText(); 
関連する問題