1 year ago

#380920

test-img

narendra natha

How to get error response of a post Request using Python aiohttp package

I am using aiohttp and could not able to get the body of the response from the servers, anyone can advise me on how to handle this.

below is the sample code.

async with session.post(url, data=data, auth=auth, headers=headers) as resp:
    return resp

form the above i need to get the error message for a particular fild,

for ex:{'username':'some username',email:"stackoverflow",password:"12345"}

The above example email format is wrong. the expectation of the response body should be as below(this is the postman response body).

{
  "code": "2004",
  "reason": "Email format is wrong",
  "errorType": "BusinessLogicError",
  "errorDetails": null
}

python

rest

aiohttp

0 Answers

Your Answer

Accepted video resources