Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

POST data on my server

Hi! I am trying to POST data from companion to my Django server.

Spoiler


fetch('https://172.25.96.56:8000/hello/', {
method:'post',
headers: {
'Content-Type': 'application/json'
},
body:JSON.stringify(evt.data)
}).then(res => res)
.then(response => console.log('Success:', response))
.catch(error => console.error('Error:', error));

The result is always TypeError: Failed to fetch

My Django server has already been running over https and I can POST data through another Python program but failed on the companion...Why would this happen? Thank you!

Best Answer
0 Votes
6 REPLIES 6

App permission would be a quick thing to check.

Your server may need CORS. I forget the details.

Peter McLennan
Gondwana Software
Best Answer
0 Votes

I have already given permission to this app also set CORS on my server.😭

I saw some other topic they said they use this way it works...I just don't know why this didn't work on my app. 😭

Best Answer
0 Votes

I think I am running into this same issue.  Was trying to test using the SendMessage app to POST data to my home automation server. . .but it isn't getting there.  I tested with the "Httper" app on my same device (where the fitbit is paired) and it successfully delivers the POST action. . .the app has permission and it will post to a server on the internet, but not one that I am trying to reach using the IP of my LAN.

Best Answer
0 Votes

Are you running https (not http) on your server?

Peter McLennan
Gondwana Software
Best Answer
0 Votes

No.  Local server is running http and accepts internal requests only.

Best Answer
0 Votes

I think that's the issue then. You can only use http with 127.0.0.1 in your companion.

Peter McLennan
Gondwana Software
Best Answer
0 Votes