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)

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

yeahh chris, restlet isn’t working at my end, but if i am using from postman  it is working.can you have idea why this happening?

thanks,

Ajeetesh

Rookie Answered on February 3, 2023.
Add Comment

Are you able to log the config object that is passed to axios? If so, could you please share.

Intermediate Answered on February 3, 2023.
Add Comment

Accept: ‘application/json, text/plain, */*’,
‘Content-Type’: ‘application/json’,
Authorization: ‘OAuth realm=”22222221_SB1″,oauth_consumer_key=”11d0f195d09c30d764a07dedd2b*****480e7e0c2c2cd0d417acc348e44f98e4″,oauth_token=”56cdaced5bb*****480352321708b70ff0c0efa987f90fca3cf3e1b9e363bfc79c”,oauth_signature_method=”HMAC-SHA256″,oauth_timestamp=1675360174,oauth_version=”1.0″,oauth_signature=”sbtD7gRFfvm5ez05Qz89OMYWfDd%2BLO9t3aZ2b3gLGLg%3D”,nonce=”acf9fb572c533c2c6e99″‘,
Connection: ‘keep-alive’,
‘Accept-Encoding’: ‘gzip,deflate,br’,
‘User-Agent’: ‘axios/0.27.2’,
‘Content-Length’: 883
},

are you looking for this?

 

Rookie 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   Become a Sponsor   Become a Sponsor