I'm wondering if anyone has successfully used an a...
# suitescript
n
I'm wondering if anyone has successfully used an api secret as an url parameter when doing a post? Here is the SA I've been using as reference https://suiteanswers.custhelp.com/app/answers/detail/a_id/100920/loc/en_US In the past, I've successfully used api secrets in the request header and when doing sftp connections but I can't seem to get it to work in the url itself.
1
b
what does your code look like
n
I tried with this two snippets and the authorization fails, if I hardcode the clientsecret it works fine
Copy code
const stURL = '*insert valid URL here*'
const stSecureClientSecret = https.createSecureString({
    input: '{custsecret_fp}'
});
const objResponse = <http://https.post|https.post>({
    url: stURL + '&client_id=' + stSecureClientSecret
    body: null
});
and
Copy code
const stURL = '*insert valid URL here*'
const stSecureURL = https.createSecureString({
    input: stURL + '&client_id={custsecret_fp}'
});
const objResponse = <http://https.post|https.post>({
    url: stSecureURL
    body: null
});
b
first attempt has no chance, adding a secure string to a string just results in a regular string
second attempt looks reasonable
post it to an echo service like
<https://www.httpbin.org/post>?
and log the response
n
I clearly don't fully understand how the secure strings work. I'll try that, thanks!!
b
you can log the url you are generating for the first attempt to see what you did to it
n
It's working now, I think I was doing some funky stuff in the code with the URL string... the httpbin tool was super helpful to debug it and find the error! Thanks a lot @battk!!