Forum Discussion
3 Replies
- floatleftinteraVisitorYup. For basic HTTP authentication, it should look something like this:
http = CreateObject("roUrlTransfer")
http.SetPort(CreateObject("roMessagePort"))
http.SetUrl("http://someurl.com")
http.AddHeader("Content-Type", "application/x-www-form-urlencoded")
ba = CreateObject("roByteArray")
ba.FromAsciiString("username:password")
http.AddHeader("Authorization", "Basic " + ba.ToBase64String())
http.EnableEncodings(true)
return http - malikVisitorThanks for your reply. I already tried it but when I check header fields in Request Header only five header fields found and the field name "Authorization" is not in the list. If I pass any dummy field name in header it is passed exactly. I found following fields in request header:
1. Content-Type
2. Accept
3. Accept-Encoding
4. Host
5. User-Agent
But the field named "Authorization" is not there. Here is my code:
http = CreateObject("roUrlTransfer")
http.SetUrl("http://someurl.com")
ba = CreateObject("roByteArray")
ba.FromAsciiString("naeem:1234")
http.AddHeader("Content-Type", "application/x-www-form-urlencoded")
http.AddHeader("Authorization", "Basic " + ba.ToBase64String())
http.Http.EnableEncodings(true)
Why "Authorization" field is not add in request header?
Thanks
Malik - RokuKevinVisitorYour line "http.Http.EnableEncodings(true)" looks out of place.
The http object in this sample is an roUrlTransfer component. There is no additional Http field for this component. Even if you changed to http.EnableEncodings(true), I don't think you are intending to enable gzip encodings.
Note that if you add the "Content-Type" header, you should be doing a POST with the properly formatted application/x-www-form-urlencoded payload.
It looks like you've implemented the Basic Auth, Authorization header correctly otherwise....
--Kevin