The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

0 votes

Hey all,

Not sure if this is the right place to ask this question, but I'm attempting to send some json data from godot to a django server. The godot-side code looks a bit like this:

var obj_to_send = {
    "field": "some data"
}

var SERVER_ADDRESS = "http://localhost:8000/django_app_name/upload"
$HTTPRequest.request(SERVER_ADDRESS, PoolStringArray(), true, HTTPClient.METHOD_POST, JSON.print(obj_to_send))

However, the django server doesnt receive anything. There isn't even a message about a connection being made--its just nothing. Does anyone know what I could be doing wrong?

Also, if this is the wrong place to ask, please let me know where would be a better place.

Any help is appreciated.

in Engine by (174 points)
edited by

I should add that when checking for what $HTTPRequest.request() returns, I get OK.

1 Answer

+2 votes

Not sure if this is the right place to ask this question

It is. :)

However, the django server doesnt receive anything.

First of, the code you provided misses a couple of things:

  1. a closing parenthesis ) in the end of the last line
  2. the value of SERVER_ADDRESS (you only define server_adddress)
  3. the value of value, thus the value of "field"

However, your problem is simply with the value of server_address:

  1. Godot apparently doesn't resolve localhost - so use the ip-address instead
  2. You don't define a port number, by default django runs on port 8000

So the following should work:

var server_address = "http://127.0.0.1:8000/django_app_name/upload"
by (10,634 points)

Works perfectly! Thanks for the help!
I also fixed up my example code so that it actually works.

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 Frequently asked questions and 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 [email protected] with your username.