Pebble-Imessager icon indicating copy to clipboard operation
Pebble-Imessager copied to clipboard

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

Open fn1y opened this issue 3 years ago • 19 comments

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 avatar May 25 '22 19:05 fn1y

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 avatar May 25 '22 19:05 fn1y

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 avatar May 25 '22 20:05 fn1y

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

fn1y avatar May 31 '22 13:05 fn1y

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.

integraloftheday avatar Jun 03 '22 00:06 integraloftheday

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.

fn1y avatar Jun 03 '22 00:06 fn1y

Okay that’s good. What are you specifically doing on the watch when the error occurs?

On Thu, Jun 2, 2022 at 5:49 PM fn1y @.***> wrote:

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.

— Reply to this email directly, view it on GitHub https://github.com/integraloftheday/Pebble-Imessager/issues/13#issuecomment-1145478505, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALFJMVE4BBEO2Y2M6XWW7YLVNFJAJANCNFSM5W6IY6FQ . You are receiving this because you were mentioned.Message ID: @.***>

integraloftheday avatar Jun 03 '22 01:06 integraloftheday

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.

fn1y avatar Jun 03 '22 01:06 fn1y

Are you using http or https? Sorry for all the questions just trying to debug!

On Thu, Jun 2, 2022 at 6:23 PM fn1y @.***> wrote:

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.

— Reply to this email directly, view it on GitHub https://github.com/integraloftheday/Pebble-Imessager/issues/13#issuecomment-1145499696, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALFJMVFGS7JXTYBCDYKL3FDVNFNC3ANCNFSM5W6IY6FQ . You are receiving this because you were mentioned.Message ID: @.***>

integraloftheday avatar Jun 03 '22 01:06 integraloftheday

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

fn1y avatar Jun 03 '22 11:06 fn1y

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

fn1y avatar Jun 03 '22 11:06 fn1y

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.

integraloftheday avatar Jun 03 '22 15:06 integraloftheday

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

fn1y avatar Jun 03 '22 16:06 fn1y

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.

integraloftheday avatar Jun 05 '22 21:06 integraloftheday

Alright, here it is

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

fn1y avatar Jun 06 '22 00:06 fn1y

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.

integraloftheday avatar Jun 08 '22 14:06 integraloftheday

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

fn1y avatar Jun 08 '22 15:06 fn1y

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

integraloftheday avatar Jun 12 '22 05:06 integraloftheday

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

fn1y avatar Jun 12 '22 14:06 fn1y

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

fn1y avatar Jul 13 '22 13:07 fn1y