Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
3581 Lượt xem
@http.route('/api/attendance/', auth='public', methods=['POST'], type='http') 
def index(self, **kw):
data = request.httprequest.data

if i use this request in postman, it will show :

Function declared as capable of handling request of type 'http' but called with a request of type 'json'

could anyone tell me how to solve this problem.


Ảnh đại diện
Huỷ bỏ

Are you sending data through the raw body with type JSON in Postman request?

Tác giả

Yes

Either you can pass data through 'params' if its HTTP request or change the request type to JSON if you want to send data through the raw body with type JSON,

@http.route('/api/attendance/', auth='public', methods=['POST'], type='json', csrf=False)
def index(self, **kw):
data = kw
print("data",data)
if data['name']:
return {
"status": "Success",
"message": "Posted Successfully"
}

Raw body with type JSON in Postman

{
"params": {
"name":"ABC",
"email":"abc@gmail.com"
}
}

Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 7 24
9003
2
thg 8 23
3503
0
thg 5 21
3503
1
thg 10 22
8736
1
thg 7 25
8360