Quality Testing

Quality is delighting customers

How we can pass query parameter while automation REST GET API using Python.

How we can pass query parameter while automation REST GET API using Python.

Views: 20

Reply to This

Replies to This Discussion

Hi

As per outsource qa below is the python code to automate REST GET API with query paramerter:


import requests
from requests_toolbelt.utils import dump

def send_Get_Request(endPoint,statusCode,params,header):
      if(params!=None):
         response = requests.get(<baseUrl>+endPoint,headers=header,params=params)
      else:
         response = requests.get(<baseUrl>+endPoint,headers=header)
      data = dump.dump_all(response)
      print("\n\n--------------Request--------------------------\n",data.decode('utf-8'))
      dataValue=response.json()
      assert response.status_code==statusCode
      #print("-----------------------JSON Response-------------------------- \n",dataValue)
      return dataValue

RSS

TTWT Magazine


Advertisement

Advertisement

Advertisement

Advertisement

© 2021   Created by Quality Testing.   Powered by

Badges  |  Report an Issue  |  Terms of Service