簡體   English   中英

415不支持的媒體類型錯誤-Domo連接器

[英]415 Unsupported Media Type error - Domo Connector

因此,我正在使用Domo開發人員工具(他們喜歡將其稱為IDE)構建連接器,但似乎無法使身份驗證文件與它們的庫一起工作。

Domo使用httprequest庫進行基本和oauth類型的身份驗證。

我在通過Domo找回令牌時遇到了麻煩,但是我可以輕松地通過curl或使用Postman api工具來完成令牌。

這是下面的代碼:

var client_id = '4969e1ea-71b9-3267-ae7d-4ce0ac6bfa28';
var client_secret = '*****************************';
var user = '*********';
var pass = '*********';

var postData =
{
  data: {
    'grant_type': 'password',
    'username': user,
    'password': pass,
     'client_id': client_id,
    'client_secret': client_secret,
    'scope': 'internal'
  }
};

var res = httprequest.post('https://rest.synthesio.com/security/v1/oauth/token', postData);

DOMO.log('res: ' + res);

請讓我知道您是否有其他解決方法。 我試圖將標題添加到postData對象本身中,以及刪除data變量,也將屬性保留為原樣。

當您將postData作為這樣的對象傳遞時,DOMO將通過JSON.stringify運行它並將結果發送到請求正文中。

您可以手動對請求正文進行編碼,也可以使用其httprequest.addParameter函數添加它們。 嘗試這樣的事情:

var client_id = '4969e1ea-71b9-3267-ae7d-4ce0ac6bfa28';
var client_secret = '*****************************';
var user = '*********';
var pass = '*********';

httprequest.addParameter('grant_type', 'password');
httprequest.addParameter('username', user);
httprequest.addParameter('password', pass);
httprequest.addParameter('client_id', client_id);
httprequest.addParameter('client_secret', client_secret);
httprequest.addParameter('scope', 'internal');

var res = httprequest.post('https://rest.synthesio.com/security/v1/oauth/token');

DOMO.log('res: ' + res);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM