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:
Authentication
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>@branchekataloget.dk/api-gateway/Branchekataloget/products?${parameters}`
xmlhttp.open("GET",url,false);
xmlhttp.send();
But get the answer:
Error in <MyScript>.js : 28:1 Expected token `;'
Hope you can point me in the right direction 🙂
Solved! Go to Solution.
And then copyed the code from Postman to the Script in Survey123:
Don't know if this was any help at all.
Regards
Martin
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.