+1 vote

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

in Engine by (21 points)

1 Answer

+2 votes

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("https://www.yousite.com", headers, ssl_true, HTTPClient.METHOD_POST, query)

it's working but have an error parsing the answer :
godot give me a
ERROR: readresponsebodychuck: Condition "status != STATUSBODY" is true

i try the same request with postman , and it's work ....
any idea ?

by (21 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.