Quality Testing

Quality is delighting customers

How we can automate REST POST API with Python Language?

How we can automate REST POST API with Python Language

Views: 35

Reply to This

Replies to This Discussion

Hi,

As per quality assurance company below is the sample of automating REST POST API:

import requests
from requests_toolbelt.utils import dump

def send_Post_Request(endPoint,statusCode,payload,header):
      response=requests.post(<baseUrl>+endPoint,headers=header,json=payload)
      data = dump.dump_all(response)
      print("\n\n--------------Request--------------------------\n",data.decode('utf-8'))
      assert response.status_code==statusCode
      dataValue=response.json()
      return dataValue

RSS

TTWT Magazine


Advertisement

Advertisement

Advertisement

Advertisement

© 2021   Created by Quality Testing.   Powered by

Badges  |  Report an Issue  |  Terms of Service