Hi there, I'm a new to suitescript and wanted to k...
# suitescript
c
Hi there, I'm a new to suitescript and wanted to know how would I go about fetching data from a third party api into netsuite ? and is it possible to see what is being returned in the console ?
c
Not enough info to be able to help. What sort of API is it? REST? How do you want to talk to it? Periodically (scheduled) / when a specific event happens / something else? You can log to the console when writing client scripts. Server-side scripts you use N/log, and can also use the NS debugger
But, to be honest, you need to start reading the documentation, maybe watch some LCS videos
Otherwise the learning curve will be more like a learning brick wall
c
It would be a REST API and as of right now it seems that it would run whenever it is triggered. I've written the code using node,js but trying to rewrite in suitescript and hit a couple blockers when trying to get logs in the debugger. Talked to Advanced Netsuite Consultant and they said they've never done anything like this and that there's no way to see JSON in netsuite so decided to do some more research on my own
Thank you for the LCS recommendation
That’s the module you need to use
The headers are the hardest bit
There’s other sample code on the documentation website
e
Check the N/http and N/https module, you can get data from REST API, GraphQL etc. You will just need to play with headers and other stuff.
👍 1
c
Throw your node code away, by the way
c
Ok got it! Thanks for the direction. And to be clear I should be using the https.request with a GET method, instead of using the https.get ?
e
To view the JSON response save the response.body to a file in the file cabinet. That way you have a "permanent" record of the data that was transmitted for future reference and processing.
👍 1