Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
3585 มุมมอง
@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.


อวตาร
ละทิ้ง

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

ผู้เขียน

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"
}
}

Related Posts ตอบกลับ มุมมอง กิจกรรม
import class from another custom module แก้ไขแล้ว
2
ก.ค. 24
9012
2
ส.ค. 23
3509
0
พ.ค. 21
3510
1
ต.ค. 22
8742
1
ก.ค. 25
8365