B4J Question Header correction

onair

Member
Licensed User
Longtime User
how to translate from java code to B4J this:
Code: Copy
httpGet.addHeader("Authorization", "Basic "+Base64.encodeToString("rat#1:rat".getBytes(),Base64.NO_WRAP));

regards
 
something like

Code: Copy
   Dim Job As HttpJob
   Job.Initialize("fcm", Me)
   Job.Download("https://www.google.com")
   'Job.GetRequest.SetContentType("application/json;charset=UTF-8")
   Job.GetRequest.SetHeader("Authorization", "Basic "&Base64.encodeToString("rat#1:rat".getBytes(),Base64.NO_WRAP))

Note that you need to set the header AFTER job.download/poststring...

Edit: The base64 you can do with stringutils and Byteconverter.
Code: Copy
su.EncodeBase64(bc.StringToBytes(USERNAME&":"&PASSWORD,"ASCII"))
 
Upvote 0
I apologize that the google translation makes no sense, but the goal is that I can make settings for the header from PHP scripts in B4J. Specifically this part of PHP code:
Code: Copy
curl_setopt($ch, CURLOPT_HEADER, 1);
        curl_setopt($ch, CURLOPT_REFERER, $this->baseurl.'/login');
        curl_setopt($ch, CURLOPT_URL, $this->baseurl.'/api/login');
 
Upvote 0
If you want to use PHP then use it.

If you want to send requests from b4j then you should use okhttputils.
Yes, you can set referer and url headers.
You just need to know the Headername (whats behind the CURLOPT_REFERER or CURLOPT_URL) to set it.

Maybe you should learn english and do not rely on faulty google translations.
 
Upvote 0
Back
Top