Quick issue solving on GCF/Python (awards the first one who gives me a message that solves the problem )
- Tình trạng: Closed
- Giải thưởng: $10
- Các bài thi đã nhận: 5
- Người chiến thắng: sriharivaila2000
Tóm tắt cuộc thi
I am building a function with Python 3.9
・request.get_json() returns None
・400 error with -H "Content-Type: application/json"
・-d '{"message":"hello"}' doesn't even work
I tried request.json() as well.
What the hell is wrong?
Here is the code
```Python
def hello_world(request):
request_json = request.get_json(force=True)
return request_json['message']
```
$ functions-framework --target hello_world
*Also tried deploying the code on actual project but no luck.
```curl
curl -X POST -d '{"message":"hello"}' "http://localhost:8080/"
#500 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.
curl -X POST -H "Content-Type: application/json" -d '{"message":"hello"}' "http://localhost:8080/"
#<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>400 Bad Request</title>
<h1>Bad Request</h1>
<p>The browser (or proxy) sent a request that this server could not understand.</p>
```
I've already built GCF with request.args/"GET" request and it works just fine.
Just strated challenging with POST and got this.
Các kĩ năng yêu cầu
Những bài dự thi tốt nhất dự cuộc thi này
-
sriharivaila2000 India
-
PcSofthelper Romania
-
Hobology India
-
yassinezero Morocco
-
albertoadell17 Egypt
Bảng thông báo công khai
Làm thế nào để bắt đầu với cuộc thi
-
Đăng cuộc thi của bạn Nhanh chóng và dễ dàng
-
Nhận được vô số Bài dự thi Từ khắp nơi trên thế giới
-
Trao giải cho bài thi xuất sắc nhất Download File - Đơn giản!