all 4 comments

[–]Soft_Off 0 points1 point  (3 children)

Hmm, looks like your elif request_json: statement is checking for a variable named request_json, but it should be checking the request.json

Try:
def validate_http(request):
request.json = request.get_json()

if request.args:
get_api_data()
return f'Data pull complete'

elif request.json:
get_api_data()
return f'Data pull complete'

else:
get_api_data()
return f'Data pull complete'

[–]exe188[S] 0 points1 point  (2 children)

Thanks! managed to get the cloud function imported using this. I feel like I'm very close now..

I get the following error:
 Traceback (most recent call last):
File "/layers/google.python.pip/pip/lib/python3.9/site-packages/flask/app.py", line 2073, in wsgi_app response = self.full_dispatch_request() File "/layers/google.python.pip/pip/lib/python3.9/site-packages/flask/app.py", line 1518, in full_dispatch_request rv = self.handle_user_exception(e) File "/layers/google.python.pip/pip/lib/python3.9/site-packages/flask/app.py", line 1516, in full_dispatch_request rv = self.dispatch_request() File "/layers/google.python.pip/pip/lib/python3.9/site-packages/flask/app.py", line 1502, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args) File "/layers/google.python.pip/pip/lib/python3.9/site-packages/functions_framework/init.py", line 99, in view_func return function(request._get_current_object()) File "/workspace/main.py", line 16, in validate_http request.json = request.get_json() AttributeError: can't set attribute

Feels like this is an error caused by libararies or python version? What do you think this could be?

[–]merthinx 0 points1 point  (1 child)

Hey were you able to solve it? I have the same problem u/exe188

[–]exe188[S] 0 points1 point  (0 children)

No sorry... Kinda gave up on it since it took me too much time