0

I am newbie to Oracle Netsuite. I read and read their API document but can't find a proper solution.

I am using Token Based Authentication and enabled it on the account setting, and created an access token.

I have an administrator account logged in via browser and created an access token through the Netsuite UI.

Below is my node code.

const axios = require('axios');

const token = 'token';

// Define the URL and headers
const url = 'https://{accountID}.restlets.api.netsuite.com/app/site/hosting/restlet.nl?script=2969&deploy=2&searchid=237';

const headers = {
    'Authorization': `Bearer ${token}`,
    'Content-Type': 'application/json'
};


// Make the API request
axios.get(url, {
    headers
})
    .then(function (response) {
        console.log(response.data.results);
    })
    .catch(function (error) {
        console.log(error.response.data);
    });

This gives an error : Invalid Login attempt.

I believe the token is correct and role is correct.

Please let me know what I am wrong.

Thank you!

I tried TBA token and account email/password. But it gives an error invalid login attempt. I also tried to enter the URL in browser and same error message shows.

I am expecting to get list of search results. Below is my Restlet script


/**
 * @NApiVersion 2.x
 * @NScriptType Restlet
 */

define(['N/search'], function (search) {

    function getSearchResultsById(context) {
        if (context.request.method !== 'GET') {
            throw new Error('Invalid request method. Only GET requests are supported.');
        }

        var searchId =237
       

        var script = search.load({
            id: searchId
        });

        var searchResults = script.runPaged().data;

        return {
            results: searchResults
        };
    }

    return {
        get: getSearchResultsById
    };

});

MT0
  • 143,790
  • 11
  • 59
  • 117
  • Most likely cause is that your token is not correct. Have you tried using Postman/cURL or similar to make a call using the token you're generating? Also, post your code that generates the token. – Krypton Apr 05 '23 at 13:02
  • I created the token using Netsuite UI. I get the same error in Postman too – Edward Mishchuk Apr 06 '23 at 20:13
  • I didn't know you could create a _token_ for TBA auth in the NetSuite UI. How are you doing that? Is it possible you're using the _token secret_ from the integration record as the token? – Krypton Apr 10 '23 at 17:10
  • In Postman you have to call the restlet using the OAuth 1.0 and Signature will be HMAC-SHA256. – HiddenOne1254 Aug 04 '23 at 09:21

0 Answers0