API testing is widely used in any professional automation framework. API allows different software components to interact with each other. HTTP is one of the methods to make HTTP calls. PUT is one of the HTTP methods which is used when the user wants to UPDATE data on the server-side.
For automaton of PUT scenario, below steps are commonly used:
Additionally, for making HTTP PUT request, below components are required to make a successful request:
This can be implemented in automation script as a reusable method in following way:
@staticmethod
def send_PUT_Request(statusCode,payload,header):
response=requests.put(<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
if(response.status_code!=statuscode.STATUS_NO_CONTENT):
dataValue=response.json()
return dataValue