I posted this in another channel, but it's core is...
# suitescript
r
I posted this in another channel, but it's core is really here in suitescript
b
keep in mind that it only works with the N/https or N/crypto modules
r
Perfect, thank you
Looks like I'm having issues pulling it into my script. I've tried the example using the ID found in API Secrets and even allowed all scripts/domains.
b
secrets (and their predecessor GUIDs ) are inconvenient to work with
the documentation for them is pretty bad
you will need to share your code and describe what problems you are having
you also probably want to learn how to use an echo service like https://httpbin.org/ so you can see what your requests look like
r
Sure, I'm making an https GET request with the following. I removed some sensitive information
Copy code
const response = https.get({
        url: 'https://<mypingpongurl>',
        headers: {
            ApiKey: 'custsecret_api_key'
        }
    });
If I change the custsecret_api_key (NS API Secrets ID) to my actual API key, it functions as expected.
b
secrets are used like data in a template
use
'{custsecret_api_key}'
1
there are rules regarding on when you have to use the credentials parameter in your request like in the Create a Form Field with a Credential Field Sample
i dont bother to memorize them and just always use the credentials parameter
r
no luck with adding the {} in the .get
I need the secret within that header, doesn't seem the request makes much different. This is used within a Suitelet to an external to Netsuite API
b
i recommend using an echo service to see what your request looks like
and to use the credentials parameter
r
reading the documentation, the credentials do not go to the headers.
b
Create a Form Field with a Credential Field Sample is the example that has a guid in the headers
it uses a SecureString instead of a template expression, but that should at least tell you that its possible
n
seems like you might have to use the createSecureString in this instance since
credentials
is not available on a
GET
since it searches bodies and body doesn't exist on a GET request
Copy code
const ApiKey = https.createSecureString({
  input: '{custsecret_api_key}'
});
const response = https.get({
  url: 'https://<mypingpongurl>',
  headers: { ApiKey },
});
1
r
Thank you all for the help, working now
🤝 1