-u Parameter cURL to HTTP Request

I am trying to make an HTTP request with the Web component, but the original documentation provides a cURL example. In that example, the documentation uses the "--user" parameter, with the account username as the first parameter and the password as the second. (e.g. -u john:pwd) What's the best way to replicate this as an HTTP request? I tried setting it as a header with the key as the username and the value as the password but that gave me an invalid authentication error.

Use the block call web request headers and make a list block

Also use this site to convert curl to block


curl's --user (or -u) parameter just adds a Basic Authorization header with value of encoding user:password in Base64.

So, using this command:

curl -u test:example https://example.com

Will create this header on request:

Authorization: Basic dGVzdDpleGFtcGxl

dGVzdDpleGFtcGxl is the Base64 encoded value of test:example

If you want to add the same header in AI2:

As servers that support Basic Authorization require encoding the User and Password in Base64, you might need a Base64 extension if you want to change the user and password every time, but if the credentials are the always same, you can just use a random online tool and put the output value in the text block. (use at your own risk, I do not recommend sharing sensitive information with such websites)

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.