Errors when trying NetSuite's Restlet interface: datain is null -
i'm trying out restlets first time , having trouble returning data.
i've built basic restlet , deployed in netsuite. code follows:
function getrestlet(datain) { return nlapiloadrecord(datain.recordtype, datain.id); // e.g recordtype="customer", id="769" }
using chromes' rest console application i've set following:
request uri: https://rest.netsuite.com/app/site/hosting/restlet.nl?script=123&deploy=1&recordtype=customer&id=2409 request headers: nlauth nlauth_account=123456,nlauth_email=email@emailaddy.com,nlauth_signature=password
running get
operation return following error:
error code: js_exception error message:type
followed following email:
date & time: 8/19/2013 2:48 pm execution time: 0.06s script usage: 0 script: getrecord type: restlet function: getrestlet error: sss_missing_reqd_argument type stack trace: getrestlet(getcustomer.js:14) restletwrapper(null$lib:3)
the customer record exists, restlet code netsuite system, , error email when script fails know deployment url good.
any ideas on i'm doing wrong?
--edit--
changing function signature function getrestlet(type,datain)
resolves type error, although get:
error code: unexpected_error error message:typeerror: cannot read property "recordtype" undefined (getcustomer.js#14)
i've removed customer
, id
request uri
, instead listed them in request payload
section of rest console.
--edit 2--
adding nlapilogexecution('debug', 'json.stringify(datain) is:', json.stringify(datain));
function returning blank log entry. appears datain null....
i had similar issue resolved once set request header content-type application/json.
the default content-type text/plain passes stringified json object function , expects string returned.
if set content-type application/json or application/xml 'datain' parameter come in javascript object.
from netsuite docs:
if users specify content type other json or text, 415 error returned following message:
invalid content type. can use application/json, application/xml or text/plain restlets.
if users provide data in format different specified type, following error returned 1 of following messages:
error code = invalid_return_data_format error message = invalid data format. should return text. error message = invalid data format. should return javascript object.
Comments
Post a Comment