Search code examples
python-3.xpython-requeststeamcityteamcity-rest-api

401 client error with Python Requests delete() method


I am using Requests module with REST API. Attempted to delete TeamCity build configuration and caught into 401 client error. curl works, see below.

curl -u admin:password -X DELETE url

But not through Requests delete() method, see below.

requests.delete(url)

Example of url is https://teamcity_server/app/rest/buildTypes/build_id


Solution

  • 401 status code means your request is unauthorized. In curl you give user:password but not in requests.delete(url). You can pass authentication parameters to requests functions in this way:

    request.delete(url, auth=('admin', 'password'))