+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

asked May 12 in Engine by stephane42 (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 ?

answered May 14 by stephane42 (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.