Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'Request' object has no attribute 'json' #13

Open
fn1y opened this issue May 25, 2022 · 19 comments
Open

AttributeError: 'Request' object has no attribute 'json' #13

fn1y opened this issue May 25, 2022 · 19 comments

Comments

@fn1y
Copy link

fn1y commented May 25, 2022

My Pebble will find my Mac on my network but won't connect. I keep getting error AttributeError: 'Request' object has no attribute 'json'.

Sorry if this is a stupid mistake on my part, I've found this tricky to set up.

@fn1y
Copy link
Author

fn1y commented May 25, 2022

Traceback (most recent call last): File "/Users/[my username]/PebbleImessageServer/lib/python3.10/site-packages/flask/app.py", line 2077, in wsgi_app response = self.full_dispatch_request() File "/Users/[my username]/PebbleImessageServer/lib/python3.10/site-packages/flask/app.py", line 1525, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/[my username]/PebbleImessageServer/lib/python3.10/site-packages/flask_cors/extension.py", line 165, in wrapped_function return cors_after_request(app.make_response(f(*args, **kwargs))) File "/Users/[my username]/PebbleImessageServer/lib/python3.10/site-packages/flask/app.py", line 1523, in full_dispatch_request rv = self.dispatch_request() File "/Users/[my username]/PebbleImessageServer/lib/python3.10/site-packages/flask/app.py", line 1509, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args) File "/Users/[my username]/PebbleImessageServer/app.py", line 66, in getReplies postData = request.json File "/Users/[my username]/PebbleImessageServer/lib/python3.10/site-packages/werkzeug/local.py", line 347, in __getattr__ return getattr(self._get_current_object(), name) AttributeError: 'Request' object has no attribute 'json' ::ffff:192.168.0.131 - - [2022-05-25 20:51:34] "POST /msg/api/v1/replies HTTP/1.1" 500 192 0.000621

@fn1y
Copy link
Author

fn1y commented May 25, 2022

Nevermind, the latest error is ::ffff:192.168.0.131 - - [2022-05-25 20:58:37] "POST /msg/api/v1/replies HTTP/1.1" 500 192 0.000591

@fn1y
Copy link
Author

fn1y commented May 31, 2022

Trying this on a brand new Pebble and still getting the error. Any way to fix this @integraloftheday ?

@integraloftheday
Copy link
Owner

Hello!
Can you confirm you have a config.json in your server folder? Additionally, did you go through the steps in Watch App Configuration and made sure both have the same key value.

@fn1y
Copy link
Author

fn1y commented Jun 3, 2022

Hi! Yes, I have a config.json and have been through the above steps in Watch App Configuration. Just in case, I redid the key generation and reinserted it into my .json, and I'm still having the same error.

@integraloftheday
Copy link
Owner

integraloftheday commented Jun 3, 2022 via email

@fn1y
Copy link
Author

fn1y commented Jun 3, 2022

I go to Settings > Data Fetch. My pebble gives me a “Server cannot be reached” error while the aforementioned appears in my Mac terminal at the exact same time.

@integraloftheday
Copy link
Owner

integraloftheday commented Jun 3, 2022 via email

@fn1y
Copy link
Author

fn1y commented Jun 3, 2022

Https, I'm using port forwarding for global access. No need to apologise!

@fn1y
Copy link
Author

fn1y commented Jun 3, 2022

I think I should mention that before I set up port forwarding I was still getting the same error.

@integraloftheday
Copy link
Owner

By chance are you using the version of the app present on the rebble store? Or did you side load the version from the github.

@fn1y
Copy link
Author

fn1y commented Jun 3, 2022

I actually have tried both, but right now I'm on the version side loaded from Github.

@integraloftheday
Copy link
Owner

The side loaded version from GitHub should be the one you want. This is odd, not an error I have encountered before. Could you share your config.json file, with the key field redacted.

@fn1y
Copy link
Author

fn1y commented Jun 6, 2022

Alright, here it is

{
"key":"[redacted]",
"port":6969,
"quickReplies":{
	"on":"true", 
	"responses":[
		"<Voice>",
		"yes",
		"no",
		"<Keyboard>"	
	]
},
"contacts":[
	{
		"buddyName":"[redacted]",
		"displayName":"Mum" 
	}
]
}

@integraloftheday
Copy link
Owner

Everything looks good there... I don't have a current server set up right now, so I can't try to do a full debug until 6/11ish.
If you wanted to try anything I would suggest putting:
print(request.data)
in line 65 of app.py to see if there is anything in the request.
Since I'm confused otherwise the request data is not being parsed or doesn't have json.

@fn1y
Copy link
Author

fn1y commented Jun 8, 2022

Alright, here's what was printed (followed with the error)
b'{"key":"[redacted]"}'

@integraloftheday
Copy link
Owner

Is the key actually in an array, or is it how you redacted it?
Is the key really "key":"Value" or "key":"[Value]"

@fn1y
Copy link
Author

fn1y commented Jun 12, 2022

I redacted it like that, the key is actually "key":"value"

@fn1y
Copy link
Author

fn1y commented Jul 13, 2022

Any updates? I understand this might be a tricky problem, I'm completely alright if it can't be fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants