How to get readable exception thrown by netsuite suitescript 2.0 using springboot

334 views Asked by At

Whenever get exceptions from netsuite suitescript 2.0 (restlet),

able to get readable exception as response like shown below, while suitescript hit from postman,

400 Bad Request

{
  "error": {
    "code": "UNIQUE_CUST_ID_REQD",
    "message": "{\"type\":\"error.SuiteScriptError\",\"name\":\"UNIQUE_CUST_ID_REQD\",\"message\":\"A customer record with this ID already exists. You must enter a unique customer ID for each record you create. To correct this record, click <a href=javascript:history.go(-1);;>back</a> and enter a new customer ID in the Customer field. Then, click Submit.\",\"stack\":[\"createError(N/error)\",\"formatAndThrowException(/SuiteScripts/ns_script.js:633)\",\"createObject(/SuiteScripts/ns_script.js:523)\",\"saveObject(/SuiteScripts/ns_script.js:552)\",\"post(/SuiteScripts/ns_script.js:503)\",\"createError(N/error)\"],\"cause\":{\"name\":\"UNIQUE_CUST_ID_REQD\",\"message\":\"A customer record with this ID already exists. You must enter a unique customer ID for each record you create. To correct this record, click <a href=javascript:history.go(-1);;>back</a> and enter a new customer ID in the Customer field. Then, click Submit.\"},\"id\":\"\",\"notifyOff\":false,\"userFacing\":true}"
  }
}

But when made same request to suitescript from spring boot, got unreadable characters as response like shown in below screenshot,

unreadable characters screenshot

request headers used in spring boot to call restlet,

[
Accept:"application/json", 
Content-Type:"application/json;charset=UTF-8",
Authorization:"OAuth realm="<ORGANIZATION_ID>",
oauth_consumer_key="<CONSUMER_KEY>",
oauth_token="<TOKEN>",
oauth_signature_method="HMAC-SHA256",
oauth_timestamp="<TIMESTAMP>",
oauth_nonce="<NONCE_VALUE>",
oauth_version="1.0",
oauth_signature="<OAUTH_SIGNATURE>",
Content-Length:"779"
]

why i can't able to get readable exception information while request made from spring boot ?

Thanks in advance

0

There are 0 answers