HTTP basic authentication method in Survey123 javascript

Jump to solution
12-16-2022 06:23 AM
New Contributor II

Hi, From a Survey123 Javascript, I would like to call an API with the HTTP basic authentication method. This is the requirement from the API supplier:

Each request requires authentication, which is performed using the HTTP basic authentication method. The header contains the authentication data in the form "Basic username:password" where the phrase "username:password" is Base64 encoded. Username and password are set individually for each external system.

I have tried with:
var url = `<MyUser>:<myPassword>${parameters}`"GET",url,false);

But get the answer:
Error in <MyScript>.js : 28:1 Expected token `;'

Hope you can point me in the right direction 🙂

0 Kudos
11 Replies
New Contributor II
Hi  Derek
No don't know what is going on with the checkmarks??
I am not a programmer so bear with me. I just did what Zach suggested and used Postman to setup the HTTP basic authentication method


And then copyed the code from Postman to the Script in Survey123: 


Don't know if this was any help at all.



0 Kudos
Occasional Contributor

Hi, @MartinBrandi - Sorry about all the comments, then. Wasn't sure why they were getting immediately checked and marked as the solution either.

Understood that you're not a programmer. Do you know how you've set up the username and password in that in order to not expose it publicly? The part that I'm most concerned with is the part that's cut off in your screenshot.

0 Kudos