POST data to Teamcity REST API url using urllib2

Hi,

I'm using Teamcity REST API to tag a build using following snippet of Python code. But I'm getting this message - TypeError: must be string or buffer, not dict

 

post_data = {"uri": "http://localhost:81/httpAuth/app/rest/builds/id:39/tags/", "name": "xxx"}
data = urllib.urlencode(post_data) 
request = urllib2.Request(url, data)

 

This is the curl command to tag a build that I'm trying to implement with urllib2.

curl -v -u user:password --request POST --header "Content-Type: application/xml" --data "<tags><tag name='xxx'/></tags>" "http://localhost:81/httpAuth/app/rest/builds/id:39/tags/
0
1 comment

Hi Munawar,

 

I'm not familiar with urllib, but that seems like it's telling you that post_data is an object but has to be a string in order for it to be urlencoded. I can't really tell whether that will work afterwards, but that seems the start of the current issue.

0

Please sign in to leave a comment.