This topic contains 3 replies, has 0 voices, and was last updated by chanarbon 7 years, 8 months ago.
-
AuthorPosts
-
sravanm- Contributions: 0
- Level 1
- ☆
Hi,
I am trying to get report and generate Saved Report data in CSV through Suitelet using Session id but it is throwing me “Must login to Netsuite” error.
Can anyone help on this
This is a cached copy. Click here to see the original post. -
chanarbon- Contributions: 0
- Level 1
- ☆
Hi sravanm
For this one, how do you access the Suitelet? Are you accessing the Suitelet through an external application using the system domain instead of the forms domain. Or are you calling it through an nlapiRequestURL() on a server script and user a session id that you have retrieved from a UI session? Or are you getting the headers from the nlobjRequest and call the report in the system domain using nlapiRequestURL()?
-
sravanm- Contributions: 0
- Level 1
- ☆
Hi Chanarbon,
Thanks for your response. In Netsuite, I am displaying suite-let link to access it. In Suite-let, I am trying to access report data using nlapiRequestURL api. Following is sample code.
var sessionID = request.getParameter(‘custpage_cookie’);
var reportID=XXXX;
var NETSUITE_REPORT_URL = ‘https://system.sandbox.netsuite.com/app/reporting/reportrunner.nl’;
var authenticationHeaders = new Array();
authenticationHeaders[‘Host’] = ‘https://system.sandbox.netsuite.com’;
authenticationHeaders[‘User-Agent-x’] = nlapiEscapeXML(‘SuiteScript-Call’);
authenticationHeaders[‘Accept’] = nlapiEscapeXML(‘application/xml’);
authenticationHeaders[‘Accept-Language’] = nlapiEscapeXML(‘en-us’);
authenticationHeaders[‘Cookie’] = sessionCookie;
authenticationHeaders[‘Content-Type’] = nlapiEscapeXML(‘application/x-www-form-urlencoded; charset=UTF-8’);
var sessionCookie = ‘JSESSIONID=’ + nlapiEscapeXML(sessionID) + ‘;’ + ‘lastUser=AccountId:-1:_-5_3;NS_VER=2016.2.0’ ;
var initialReportRequestURL = NETSUITE_REPORT_URL + ‘?cr=’ + reportID;
var responseObjectGenerateReport = nlapiRequestURL(initialReportRequestURL, null, authenticationHeaders);
Do let me know if anything need to be added/modified
-
chanarbon- Contributions: 0
- Level 1
- ☆
Hi @sravanm
From my point of view, the problem is to where you are sourcing the session id. Have you tried sourcing it from the session object of the request or have you retrieved the cookie header of the request itself.
-
AuthorPosts
You must be logged in to reply to this topic.