通过 rapidapi 的 NetSuite SuiteScript 连接

NetSuite SuiteScript connection via rapidapi

我在 NetSuite 中使用 RapidApi 时遇到问题。有人做过吗?

headersObj = [
    {
        name:"x-rapidapi-host",
        value:"hostishere"
    },
    {
        name:"x-rapidapi-key",
        value:"keyishere"
    }
];

response = https.request({
    method: https.Method.GET,
    url: "MyURLishere",
    headers: headersObj
});

我得到以下 return:

error 400 message: Invalid API key. Go to https:docs.rapidapi.com/docs/keys for more info.

通过postman测试API密钥正确

如果您是从 Netsuite 中拨打电话,则需要使用他们的 https 库:

define(["N/https"], function(http){
    headersObj = [{ name:"x-rapidapi-host", value:"hostishere" }, { name:"x-rapidapi-key", value:"keyishere" }];
    var resp = http.get({url:'your url', headers:headersObj});
    // do something
});

header 缺少“接受”:“application/json”。

headersObj = {
    "Content-Type": "application/json",
     "Accept":"application/json",
     "x-rapidapi-host": "Myhost",
     "x-rapidapi-key": "Mykey",
     "Host": "host"
};