Codless http request how to add basic Authorization header

what is the correct way to add basic Authorization header to the http request

This is the api im trying to connect to:

curl 'https://api.twilio.com/2010-04-01/Accounts/ACb8ac29aac593677cbf/Messages.json' -X POST \
--data-urlencode 'To=+96655555555 \
--data-urlencode 'From=+9665555555' \
-u ACb8ac29aac593677cbf9a7bcc4fd005cb:[AuthToken]

Hi Mohammad

If you use “HTTP/s” block you can specify any headers what you need

Regards, Vlad

Thanks Vlad for your replay.
here is my block, i did as you ask but still i got this response

400 - Authentication Error - No credentials provided (20003)

I believe “ACb8…” is not a valid header, you should have something like this:

Thanks i think we are close but i still get the error. here is my block
the authorization is Basic
so something like this in jquery

headers: {
    "Authorization": "Basic " + btoa(USERNAME + ":" + PASSWORD)
  },

Where is the word "Basic " in your logic?

there isn’t any
so i tried adding another text on top with "Basic " on the header
no luck
Edit
here is an image

1 Like

Your format is wrong. You’re missing space after the word “Basic” and userid and password must be separated by colon. The entire value of the concatenated user id and password should be base64 encoded. Read more about it here: https://en.wikipedia.org/wiki/Basic_access_authentication

i did add the space after the Basic and added the colon then encoded with base64 the user and pass
still the same error “No credentials provided”

Did you read the page for the link I included in my previous reply? It does include step-by-step algorithm for constructing the header value. Here it is:

im sorry but how can i do that with codeless?

i did it!
thank you for the support @vladimir-upirov @mark-piller
i got another error now that about missing body. i will try to fix it.

@mark-piller i have been trying all yesterday to complete the API request but i still couldn’t figure it out.
the authorization header works ok but im not able to send any data with the request.

--data-urlencode 'To=+96655555555 \
--data-urlencode 'From=+9665555555' \
  1. take user id and password
  2. concatenate like this:
    userid:password
  3. do base64 encoding of the combined value
  4. create Authorization header with value:
    Basic base64-encoded-value-from-step3

Did you do that?

yea i did that yesterday and it worked for the authorization perfectly

im talking about sending the parameters for the request.
here is what i have right now. and you can see the error on the right.

The error message says it all : Message body is required. Your code doesn’t send anything for the message body.

in query there is a Create Object and Body

is this not correct?

i did try that yesterday too with same result.
twilio error mean the message body is missing. not the request body.

Do you have an example of a working request? Perhaps with curl or with Postman?