Hey guys, trying to get api secret like: var secre...
# suitescript
n
Hey guys, trying to get api secret like: var secret = 'custsecrettest1_password'; but when I log it or send it in body it doesn't send the password/key it gives me invalid key and sends the id of secret instead of the value of secret. Kindly correct me!
e
n
I have tried https://suiteanswers.custhelp.com/app/answers/detail/a_id/100920/loc/en_US as well. but its not working either.
Could you provide me a basic code snippet if possible? or share me link where I can look at?
Copy code
/**
* @NApiVersion 2.x
* @NScriptType UserEventScript
*/

define(['N/https', 'N/url'], function(https, url) {
function myLogin(context) {
    var secret = 'custsecrettest1_password'; // <<<<< Your API secret ID
    var baseUrl ="<https://home.mcddddd.com/sandbox/private/login.php?username=Tim>";
    var authUrl = baseUrl + '&password={' + secret + '}';
    var secureStringUrl = https.createSecureString({
        input: authUrl
    });

    // Assemble the whole string
    var response = https.get({
        url: secureStringUrl
    log.debug(response.body);
    log.debug('Password Used =' + secret);
}
return {
    afterSubmit:myLogin
};
});
Can we get it like this? @erictgrubaugh
I tried this as well but still its giving me the id of secret field not the value that i store inside.
e
You can't log the value of a secret or it wouldn't really be a secret anymore. The Help docs I linked above have examples, and there are more here
n
okay , thanks! we can concatenate it but what if I have to put that key/value inbetween the url not concate it at end!! I tried putting the apiKey in it but it doesn't work
e
You don't have to concatenate at the end, I believe you just insert
{secret_id}
(including the braces) wherever you want it to be replaced within your string
n
I'm trying to pass apiKey and password via XML body. but when I keep that secret there. its not working.