Im having a problem with get/post a list from/to REST server with Unity 3D and C#.
My server:
from flask import Flask, jsonify
import requests, json
app = Flask(__name__)
url = "http://0.0.0.0:5000/"
list = ["1","2","3","4"]
@app.route('/')
def index():
return "Hello"
@app.route('/list', methods=['GET'])
def get_tasks():
return jsonify(list)
if __name__ == '__main__':
app.run(host="0.0.0.0", port = 5000,debug=True)
How do i Download the list of objects in Unity and save it to a variable? Also how do i post/update another list? https://docs.unity3d.com/Manual/UnityWebRequest-CreatingDownloadHandlers.html
with this tutorial i got the "Hello" text returnet but it only returns "1" when using
byte[] results = www.downloadHandler.data;
Debug.Log(results)
edit: my Python client:
import json
import requests
list = " "
api_url = 'http://ipaddress:5000/list/'
r = requests.get(url = api_url, json=list)
a = r.content
if "3" in a:
print "found"
When client is ran, it prints "found" so it returns the wole list. in Unity i get: [1,]