Http request using Basic Auth ?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By stephane42

Hi all ,

I am trying to set up REST requests, but I have not found any example using basic auth.
does anyone have any example links ?

in attempt to make it work , i try also UNIREST GDSCRIPT ( github repo)
But it doesn’t seem to be compatible with Godot 3.2 ( new() keyword ? )

is there a newest version of that lib ?

thank’s in advance

:bust_in_silhouette: Reply From: stephane42

To answer to myself ( and may be it cant help other)
you can have auth headers to requests with

var auth=str("Basic ", Marshalls.utf8_to_base64(str(user, ":", password))) 
var headers=["Content-Type: application/json","Authorization: "+auth]

HTTPRequest.request("", headers, ssl_true, HTTPClient.METHOD_POST, query)

it’s working but have an error parsing the answer :
godot give me a
ERROR: read_response_body_chuck: Condition “status != STATUS_BODY” is true

i try the same request with postman , and it’s work …
any idea ?