How do I communicate to web servers/APIs in Godot?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By JoaoCesar
:warning: Old Version Published before Godot 3 was released.

I need to comunicate to a client’s web server. He sent to me the following info to make the request and get back a list of JSON items.

Url: https://api-prod.company.com.br…product/listProducts
Method: GET
Headers:
Content-Type: application/json
token: hLmNvbS5iciIsImV4cCI6MTQ3NDQxMTE…frwYXNchyNJMZTzZV4omjFS0Rzk9I_JsOQw
Body: {}

I’m using the request() method of the HTTPRequest node but I’m getting the error in the image below. How do I communicate to web servers/APIs in Godot?

enter image description here

"OpenSSL error queue may contain more information on the error"

Maybe it is a certificate issue since ur using https, is it a self signed certificate ?
does it give u any error if u open the same link in the browser ?

Btw, did u follow those instructions :

http://docs.godotengine.org/en/stable/tutorials/ssl_certificates.html

They are mandatory and worked in my case.

GameVisitor | 2016-11-28 16:53

Hi! Thank you for the answer.

Actually I don’t know. Never used or needed something like this.

Do you have an example of how I could create this certificate specifically for Godot? Would the certificate file wrap or contain this long encryption key that I have?

Sorry, but I’m really a total noob on making request and stuff.

JoaoCesar | 2016-11-28 19:47

No, certificates are not made “for Godot”, these are standard SSL certificates :
Certificate authority - Wikipedia

Under Linux you can import all knows certificates by using this file:

/etc/ssl/certs/ca-certificates.crt

Just import it into Godot (in project settings) and you’re ready to go (In case the server is not using a self signed certificate !)

As a first step, import the .crt file i mentioned and try to make an https request to Google, if it works then your import is working (then you go into detail about your specific server)

Goodluck !

GameVisitor | 2016-12-01 20:45