Posts

Showing posts from December, 2019

Requests Library in Python

Image
   Concept Python requests Library is used For API testing as well as API calls within a python script. By using the requests Library we can get a response as well as we can post, updated, delete data. This is mainly used for API calls with py script even we can use API token we can change the content type. Code Step 1: pip install requests Now it is ready to use Example 1: res = requests.get(url=<Your URL>, headers={ 'Accept': 'application/json', ...... }) print(res.status_code)    # ----- > you will be getting status code of response print(res.text)   # ------> response body print(res.content)   # ------> response body Example 2: res = requests.get('https://api.github.com/user', auth=('<Your Git Username>', '< Your Git Password>')) """ You will be able to login  in git by using request Lib """ print( res.headers['content-type'] ) print(res.json())   # ----> print the respons