RE: SS1.0 – PUT requests for RESTlets

Hi all,

Newbie here to NetSuite! I was just wondering if anyone might know how to run a PUT request through a NetSuite RESTlet using SuiteScript 1.0? Do you need to use HTTPS type methods (this seems to be recommended for SS2.x), or can you do something similar to POST requests using pre-existing/ inbuilt functions like nlApiSubmitRecord?

The reason I’m wondering is, I have a POST request currently up and running and haven’t had to use any sort of outright declaration for HTTPS headers/ methods within the RESTlet (though I assume the aforementioned one would have something to do with it). That’s why I guess I was just wondering if maybe there could be some sort of commonality for PUT requests as well that I could try and implement, or whether the primary / recommended pattern for implementing this kind of problem is to just use HTTPS requests in the RESTlet as well?

Thank you in advance (and sorry for the total newbie question)

yvonnen Rookie Asked on August 8, 2021 in SuiteScript.
Add Comment
1 Answers

Hi all – I’ve found the answer to my own question and thought I might post it here in case it can help others down the line.

You can use nlapiSubmitRecord to both submit AND update a current record, so you don’t need to do anything different between POST and PUT requests really (in terms of the fields – i.e. I don’t need to duplicate my code and then somehow slightly alter every single field call I want to update). Similarly, you can use setFieldValue to set new values/ update existing fields, instead of having to rely on any other NetSuite library. Just use nlapiLoadRecord to find existing records, instead of nlapiCreateRecord (for fairly obvious reasons), and pop an if statement into your function to decide if you’re going to create the record, or find the existing one to update.

Thanks

Rookie Answered on August 8, 2021.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.