This topic contains 5 replies, has 0 voices, and was last updated by Daniel Giguere 8 years, 8 months ago.
- 
		AuthorPosts
- 
March 13, 2016 at 7:24 am #6746
 NicJust trying to call the basic Hello World RESTlet. I just want to call the RESTlet through the URL to start with. I have also tried this using Postman extenstion as well. …..deploy=1&NLAuth nlauth_account=11111, nlauth_email=my@email.com, nlaut…. …..deploy=1&(Authoirzation: NLAuth nlauth_account=11111, nlauth_email=my@email.com, nlaut…) …..deploy=1&nlauth_account=11111&nlauth_email=my @email.com&nlaut…. I have tried many different combinations, but I still get 401 error, no authorization header. 
 This is a cached copy. Click here to see the original post.
- 
March 13, 2016 at 8:32 am #6747
 JohnCColeYour passing the NLAuth parameters in the Authorization header right? Your examples sort of indicate your passing these as url parameters. 
- 
March 14, 2016 at 8:40 am #6748
 roberthThe header should look like this: authorization = ‘NLAuth nlauth_account=111111,nlauth_email= username,nlauth_signature=password,nlauth_role=role’ 
- 
March 14, 2016 at 11:01 am #6749
 NicOkay thanks. I was a little confused about the header, I thought maybe it could be passed through the URL as well, but now see how to do it. I guess the header gets passed through the wire or something like that. I was able to do it with cURL. Code: 
 curl -X GET -H ‘Authorization: NLAuth nlauth_account=xxxxx,nlauth_email=xxxxxx,nlauth_signature=xxxx, nlauth_role=x’ -H ‘Cache-Control: no-cache’ -H ‘Content-Type: application/json’ ‘https://rest.netsuite.com/app/site/hosting/restlet.nl?script=228&deploy=1’
 Hello world was successful. Now I am trying to POST using the example in NetSuite and create a new record, but I keep on getting a combination of the following errors no matter what I trycant resolve host companyname, cant resolve host subsidair …. SYNTAX_ERROR”, “message” : “SyntaxError: Empty JSON string (null$lib#3).”}} Any insight into the this? Code: 
 curl -X POST -H ‘Authorization: NLAuth nlauth_account=xxxxx,nlauth_email=xxxxxx,nlauth_signature=xxxx, nlauth_role=x’ -H ‘Cache-Control: no-cache’ -H ‘Content-Type: application/json’ ‘https://rest.netsuite.com/app/site/hosting/restlet.nl?script=228&deploy=1’ {“recordtype”:”customer”,”entityid”:”John Doe”,”companyname”:”ABCTools Inc”,”subsidiary”:”1″,”email”:”jdoe@email.com”,”entitystatus”:”CUSTOMER-Closed Won”}
 NetSuite Sample POST RESTLetCode: 
 // Create a standard NetSuite record function createRecord(datain) { var err = new Object(); // Validate if mandatory record type is set in the request if (!datain.recordtype) { err.status = “failed”; err.message= “missing recordtype”; return err; } var record = nlapiCreateRecord(datain.recordtype); for (var fieldname in datain) { if (datain.hasOwnProperty(fieldname)) { if (fieldname != ‘recordtype’ && fieldname != ‘id’) { var value = datain[fieldname]; if (value && typeof value != ‘object’) // ignore other type of parameters { record.setFieldValue(fieldname, value); } } } } var recordId = nlapiSubmitRecord(record); nlapiLogExecution(‘DEBUG’,’id=’+recordId); var nlobj = nlapiLoadRecord(datain.recordtype,recordId); return nlobj; }
- 
March 15, 2016 at 6:20 am #6750
 NicIt this helps anyone, the syntax is curl -X POST -H ‘NLAuth’ -H ‘Content-Type: application/json’ -d ‘{“key”:”val”}’ URL 
- 
March 16, 2016 at 8:48 am #6751
 Daniel GiguereHi Nic, This syntax looks good. Did you get it working? Some things about curl calling RESTlets: URL should be enclosed in quotes due to the ‘&’ in the URL. If you have special characters in the NLAuth string, they should be URL encoded (e.g. if you have ‘!’ in password, replace by %21 . if you have + in email, replace by %2B , etc.). This should work: Code: 
 curl -X POST -H “Content-Type: application/json” -H “Authorization: NLAuth nlauth_account=xxxxx,nlauth_email=xxxxxx,nlauth_signature=xxxx, nlauth_role=x” -d ‘{“recordtype”:”customer”,”entityid”:”John Doe”,”companyname”:”ABCTools Inc”,”subsidiary”:”1″,”email”:”jdoe@email.com”,”entitystatus”:”CUSTOMER-Closed Won”}’ “https://rest.netsuite.com/app/site/hosting/restlet.nl?script=228&deploy=1”
- 
		AuthorPosts
You must be logged in to reply to this topic.
