I am trying to use Restlet api using oauth 1.0 and i am getting this issue

I am trying to use Restlet api using oauth 1.0 and i am getting this issue

 

I am trying to create sales order using restlet api, how can i paas authentication using nodejs?

Add Comment
19 Answer(s)

Hi,

One thing that’s worth checking is the order as I think NetSuite can be a bit fussy about this. It should be:

realm

oauth_consumer_key

auth_token

oauth_signature_method

oauth_timestamp

oauth_nonce

oauth_version

oauth_signature

Let me know if this makes any difference.

Thanks,

Chris

Intermediate Answered on February 3, 2023.
Add Comment

Apologies – I’ve just been checking my facts and the order might not be too important in the header but it is certainly important when constructing the signature.

As next steps, I would recommend checking the Login Audit Trail:
Setup > Users/Roles > View Login Audit Trail – Make sure to add a column for “Detail”.

And checking that your signature generation code produces the expected result based on the example on this page:
https://suiteanswers.custhelp.com/app/answers/detail/a_id/77576#subsect_1520523189

Intermediate Answered on February 3, 2023.
Add Comment

Since this is a custom RESTlet script, it all depends on what is happening in that script.

However, this may be useful:

https://suiteanswers.custhelp.com/app/answers/detail/a_id/97332/loc/en_US

Intermediate Answered on February 6, 2023.
Add Comment

This doesn’t look like an authentication issues.

Could you please send us a snippet of the code you’re currently using.

Intermediate Answered on February 2, 2023.
Add Comment
Hey @chris, I am sharing the whole snippet can you please like to check this and let me know. Thanks in advance buddy
const SyncNewOrdersWithRestlet = async function (req, res) {
constRestletConfig = awaitgetConfig();
//let data_array = {…}
console.log(RestletConfig.NONCE, “with encoding”, encodeURIComponent(RestletConfig.SIGNATURE))
console.log(“Timestamp”, RestletConfig.TIMESTAMP)
letconfig = {
method:”POST”,
url:”https://7267001-sb1.restlets.api.netsuite.com/app/site/hosting/restlet.nl?script=569&deploy=1″,
headers: {
Authorization:`OAuth realm=”${RestletConfig.ACCOUNT_ID}”,oauth_consumer_key=”${RestletConfig.CONSUMER_KEY}”,oauth_token=”${RestletConfig.TOKEN_ID}”,oauth_signature_method=”HMAC-SHA256″,oauth_timestamp=”${RestletConfig.TIMESTAMP}”,oauth_nonce=”${RestletConfig.NONCE}”,oauth_version=”1.0″,oauth_signature=”${encodeURIComponent(RestletConfig.SIGNATURE)}”`,
“Content-Type”:”application/json”,
“Connection” :”keep-alive”
},
data:JSON.stringify(data_array),
};
// return false
axios(config).then(async () => {
// console.log(“————–“,response);
console.log(“ORDER SYNC SUCCESS”);
}).catch(({ response }) => {
// console.log(“FAILED”);
console.log(“here response started”,response);
});
};
Rookie Answered on February 3, 2023.
Add Comment

Hi,

There’s nothing that looks majorly wrong here.

Do you get anything logged in the RESTlet itself?

Thanks,

Chris

Intermediate Answered on February 3, 2023.
Add Comment

No. could you please like to share a snippet???It would be great help, I am trying from last 3 days??

Rookie Answered on February 3, 2023.
Add Comment

You are targeting this script: script=569&deploy=1

Could you please share the contents.

Intermediate Answered on February 3, 2023.
Add Comment

what contents you are looking for ? Is that the whole function?

below i writing down the whole function please check this,if you found any error please let me know-


const SyncNewOrdersWithRestlet = async function (req, res) {
constRestletConfig = awaitgetConfig();
letdata_array = {…}
console.log(RestletConfig.NONCE, “with encoding”, encodeURIComponent(RestletConfig.SIGNATURE))
console.log(“Timestamp”, RestletConfig.TIMESTAMP)
letconfig = {
method:”POST”,
url:”https://****001-sb1.restlets.api.netsuite.com/app/site/hosting/restlet.nl?script=569&deploy=1″,
headers: {
Authorization:`OAuth oauth_consumer_key=”${RestletConfig.CONSUMER_KEY}”,oauth_nonce=”${RestletConfig.NONCE}”,oauth_signature_method=”HMAC-SHA256″,oauth_token=”${RestletConfig.TOKEN_ID}”,oauth_timestamp=”${RestletConfig.TIMESTAMP}”,oauth_version=”1.0″,oauth_signature=”${encodeURIComponent(RestletConfig.SIGNATURE)}”`,
“Content-Type”:”application/json”,
“Connection” :”keep-alive”
},
// realm=”${RestletConfig.ACCOUNT_ID}”
data:JSON.stringify(data_array),
};
// return false
axios(config).then(async () => {
// console.log(“————–“,response);
console.log(“ORDER SYNC SUCCESS”);
}).catch(({ response }) => {
// console.log(“FAILED”);
console.log(“here response started”,response);
});
};
module.exports.SyncNewOrdersWithRestlet = SyncNewOrdersWithRestlet;
Rookie Answered on February 3, 2023.
Add Comment

Hi,

This is your code that is POSTing into NetSuite to this script:

https://****001-sb1.restlets.api.netsuite.com/app/site/hosting/restlet.nl?script=569&deploy=1

That is a RESTlet and so there should be code at the NetSuite side that is responding to this call.

Is this what you’re looking for or were you looking to use the standard REST Web Services?

Thanks,

Chris

Intermediate Answered on February 3, 2023.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.
  • This site made possible by our sponsors:   Tipalti   Celigo   Limebox   Become a Sponsor   Become a Sponsor