Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
3550 Visualizzazioni
@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.


Avatar
Abbandona

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

Autore

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

Post correlati Risposte Visualizzazioni Attività
2
lug 24
8962
2
ago 23
3432
0
mag 21
3475
1
ott 22
8683
1
lug 25
8309