如何使用Google Apps脚本连接到Tableau Online? [英] How to connect to Tableau Online using Google Apps Script?
本文介绍了如何使用Google Apps脚本连接到Tableau Online?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望使用URLfetChap服务并通过个人访问令牌进行身份验证。我试着在这里利用这些文件: https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_authentication.htm#sign_in
到目前为止,我可以做到这一点,但遗憾的是,这并不起作用。
function myFunction() {
var payload = {
'method' : 'post',
'muteHttpExceptions' : true,
'contentType': 'application/json',
'credentials': {
"personalAccessTokenName": "Tableau Token",
"personalAccessTokenSecret": "token secret",
"site": {
"contentUrl": "explore"
}
}
}
var response = UrlFetchApp.fetch("https://10ay.online.tableau.com/api/3.13/auth/signin",payload);
Logger.log(response)
}
推荐答案
UrlFetchApp.fetch()
按顺序接受两个参数:
- URL
- 选项
options
与payload
不同。payload
是请求正文:
function tableauTM() {
/*changed name*/ const options = {
method: 'post',
muteHttpExceptions: false,
contentType: 'application/json',
/*added new param 'payload'*/ payload: /*added JSON.stringify*/ JSON.stringify(
{
credentials: {
personalAccessTokenName: 'Tableau Token',
personalAccessTokenSecret: 'token secret',
site: {
contentUrl: 'explore',
},
},
}
),
};
const response = UrlFetchApp.fetch(
'https://10ay.online.tableau.com/api/3.13/auth/signin',
/*changed*/ options
);
/*added method*/ console.log(response.getContentText());
}
这篇关于如何使用Google Apps脚本连接到Tableau Online?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文