CoolCoderSJ / HCGateway

A universal REST API for apps like Google Fit, Fitbit, Samsung Health, and more utilizing the Android Health Connect API.
https://hcgateway.shuchir.dev/
GNU General Public License v3.0
112 stars 22 forks source link

Internal Server Error #11

Closed ubed201 closed 1 month ago

ubed201 commented 1 month ago

whenever i try to fetch the data i get this error 500 Internal Server Error

Internal Server Error

The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

CoolCoderSJ commented 1 month ago

It's possible your user account might not have been created properly. I'm currently working on implementing proper error tracking- in the meantime I can simply look through logs. Logs are saying a user account failed to create (right around when you made this issue) for the following reason:

appwrite.exception.AppwriteException: Invalid `password` param: Password must be between 8 and 265 characters long, and should not be one of the commonly used password.

Your sync is failing because it seems to be missing a user id. I'm not quite sure how this is happening since the app requires you to log in before it lets you sync- how are you navigating the app? I would clear all data for the app and try again.

Your fetch requests are failing because the user isn't a valid one, presumably because the account was never created. Is the server giving you a user id back when you try hitting the login endpoint? What user id are you providing the server with?

ubed201 commented 1 month ago

i am using user id sentech2 when i try to fetch the login i get the session id in response but when i try to get some methods eg heart rate its give me server error i am using this command from terminal curl -X POST https://api.hcgateway.shuchir.dev/api/fetch/bloodGlucose \ -H "Content-Type: application/json" \ -d '{"userid": "sentech2", "queries": ["limit(10)"]}'

CoolCoderSJ commented 1 month ago

sentech2 is your username, not a valid userId. a userId is a randomized string of letters/numbers provided by the server. Please look at the /api/login endpoint in the readme to see how to get your userId.

ubed201 commented 1 month ago

thanks for the quick response i made the new user but i am still facing same issue curl -X POST https://api.hcgateway.shuchir.dev/api/fetch/heartRate \

-H "Content-Type: application/json" \ -d '{"userid": "sentechhealth", "queries": ["limit(10)"]}' <!doctype html>

500 Internal Server Error

Internal Server Error

The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

CoolCoderSJ commented 1 month ago

Are you sure you are receiving a valid userId back when you create an account? Your user was not created.

AppwriteException
Invalid `password` param: Password must be between 8 and 265 characters long, and should not be one of the commonly used password.
CoolCoderSJ commented 1 month ago

Thank you- deleted for privacy. I see your user on the database now. just make sure you're using the value from sessid for your requests. The latest request still seems to be using your username.

ubed201 commented 1 month ago

thank you command works now but i think my data is now getting synced from the app i get this error {"error":"no database found for user"} can u check if my userid have some data [redacted for privacy]

CoolCoderSJ commented 1 month ago

The new userId you provided doesn't have any data- not sure why that is at all. However, I also see that as a new user- to clarify, you don't need to make a new account with that userId. Let me describe a quick flow the requests should follow:

You POST to /api/login with a username like sentech, etc. You receive a userId from the attribute sessid in the response You use this value as the "userId" in the fetch method