Hello @SuhaibBaba
Where did you get that ‘solution’? In the article linked to that Google result it contains an example that shows that REST API endpoint uses a POST method, not a PUT method.
You also might try referring to the REST API documentation where it says the same:
Create a commit by uploading a file
POST /2.0/repositories/{workspace}/{repo_slug}/src. This endpoint is used to create new commits in the repository by uploading files.
Anyhow, good luck on your learning adventure.