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.

asked May 15 in Engine by Bush2Tree (50 points)
edited May 15 by Bush2Tree

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"
answered May 15 by njamster (8,874 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 How to use this Q&A? before posting your first questions.