1

I have to trigger a pipeline in Azure DevOps from a python script. I have already found out that i need a private access token and that part is fine. I can, however, not get the script to work. I am trying something like this:

data = [
     {
     }
    ]
http = urllib3.PoolManager()
    r = http.request('POST', api_url, headers={'Content-Type': 'application/json-patch+json', "Authorization": private_access_token}, body=data)
    print(r.status)
    print(r.data)

Its a requirement that i have to use urllib3 because I cant use the requests package

data is empty, because looking at the parameters here https://learn.microsoft.com/en-us/rest/api/azure/devops/pipelines/runs/run%20pipeline?view=azure-devops-rest-6.0. Then i dont need any input data? I just want to trigger a pipeline, nothing else

Error message is not very helpful. I get error message 203.

1 Answer 1

1

I solved it by using:

authorization = str(base64.b64encode(bytes(':'+private_access_token, 'ascii')), 'ascii')
    data = {}
    a = json.dumps(data)
    http = urllib3.PoolManager()
    r = http.request('POST', api_url, headers = {'Content-Type': 'application/json', 'Authorization': 'Basic '+authorization}, body=a)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.