rest api POST method

Hello,

I think the first thing I should note is that I am new to wadl, and that I am using a set of functions to interact with the Team City Rest wadl. One of these functions is defined as follows:

    # def addBuildTag(self, build, tag):
    # ...
    # headers = {'Content-Type': 'application/json', 'Accept': 'application/json'}
    # d = json.dumps({'tag': tag})
    # return self.makeRequest('httpAuth/app/rest/builds/%d/tags' % (buildId,), method='POST', data=d, headers=headers)

where self.makeRequest prepends http://<our_server>/ to the url you see passed to it as a paramter. Here is the first question: How would someone using this function know to use 'tag' as the key in the key value pair in the dictionary passed in as the 'data' parameter?  It is the only way I see for the makeRequest function to tell this particular 'POST' function apart from the addTags function. However, I do not see any reference to the word 'tag' in the wadl documents except for a single line in the 'wadl/xsd1.xsd' document:

<xs:complexType name="tags">
     <xs:sequence>
          <xs:element name="tag" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>

     </xs:sequence>

</xs:complexType>


and in this line, there is nothing to associate it with the '{buildLocator}/tags/addTag' function.

http://<our_server>/httpAuth/app/rest/builds/{buildLocator}/tags/ is shown in the screenshot below:
tags_functs.png

2 comments
Comment actions Permalink

On a side note, I noticed that the headers passed to the self.makeRequest function {'Content-Type': 'application/json', 'Accept': 'application/json'} correspond to the <representation> tag in every method defined in '{buildLocator}/tags/' except the addTag method.. It does not make sense to me that the headers, if they do correspond to the <representation> tags, would not match the contents of the representation tag of the method they are being used with. Any ideas?

0
Comment actions Permalink

Vincent,

Sorry for the delay in replying.

The confisuion here seems tobe related to the fact that there are two POST requests to the same tags URL with different acceptable types.

The highlighted area of the wadl describes POST which accepts plain/text. You can indeed POST plain text tag name to the URL.

What you use in the request is POSTing application/json to the same URL. That is described a bit below in the wadl (also in the screenshot) and indicates "tags" as the representation. Basicallym the same "tags" which is returned from GET to the URL. So here you can "easily" guess format for POSTing via the format returned on GET request.

0

Please sign in to leave a comment.