I have a probelm where I do not know how to fix this error.
I am programming a small app, that should manage the webook alert from tradingview.com with flask. But i get always the same error:
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
the server error ist like this
500 INTERNAL SERVER ERROR
the small script is this:
import json
from flask import Flask, request
app = Flask(__name__)
@app.route("/Webhook", methods=["POST"])
def Webhook():
data = json.loads(request.data)
print(data["Price"])
return{
"code": "success"
}
if __name__ == '__main__':
app.run(debug=True)
something is wrong with this line:
data = json.loads(request.data)
but what is also weird: When i send a webhook signal from this script, everything works fine:
import requests
import json
webhook_url = "https://NaN(Private).ngrok.io/Webhook"
data = {"Price": "135000", "Side": "Buy"}
r = requests.post(webhook_url, data=json.dumps(data), headers={"Content-Type":"application/json"})
I also use ngrok.io for hosting a public IP