Has anyone ever used an external Suitelet to gener...
# suitescript
j
Has anyone ever used an external Suitelet to generate an OAuth Header to send to an external Restlet?
b
beyond the general statement that you are better off calling the restlet code as a custom module from the suitelet
the internal url for a restlet requires that the jsessionid cookie be set to a valid value
the external url for a restlet is the one that uses oauth headers
if you still want to try generating oauth headers, i recommend OAuth 1.0a, which can be used with crypto-js to do the hashing. use the older 3.3.0 version of crypto-js
j
Sorry yes, the restlet is actually external (oops). It’s just expecting headers to be sent from whatever is calling it (currently a PHP script). Hoping to call it from somewhere within NetSuite instead, that can generate the headers instead of the PHP script doing that.
I’m not sure how to use Node in NetSuite though 😞
b
both packages are written to support both browsers and node
those kind of packages are most likely to work in netsuite
my primary advice to you is to use the code in the restlet as a custom module in your suitelet
if for whatever reason that doesnt work, use the 2 packages from npm to generate the headers for you
the alternative is doing the crypto yourself, which is easy to get wrong
j
I’m stuck again because my external system can’t seem to call the Suitelet (external URL works in the browser but not elsewhere, such as using curl). I just get “This request is missing a required parameter.”
Basically I have a Slack - NetSuite integration, but Slack can’t send the OAuth headers, so right now I have a PHP script working as a go-between to build the headers. So it goes Slack -> PHP Script -> RESTlet. But we want to remove the PHP Script and just go straight to NetSuite. So I was hoping to use a Suitelet to build the OAuth headers. Slack -> Suitelet -> RESTlet.
b
do the restlet as a custom module so its only slack -> suitelet
keep in mind that suitelets have requirements for acceptable headers, so make sure to test slack with the suitelet before going too far down the oauth route
j
That’s the issue, the Suitelet only seems to work in a browser
b
if you are getting a 405 status error, its probably because of the user agent
j
I think so too. But I can’t send/edit the headers
this is so frustrating