How to programmatically create a collection on GSA with Python



I am attempting to create a collection on a Google Search Appliance using the Administrative API


I successfully retrieve an authorization token but when posting XML to create the collection I get errors about my xml.



<errors xmlns=\'http://ift.tt/17PKlnd\'><error><domain>GData</domain><code>ParseException</code><internalReason>Element type "gsa:content" must be followed by either attribute specifications, "&gt;" or "/&gt;".</internalReason></error></errors>


Here is my payload:



<?xml version='1.0' encoding='UTF-8'?>
<entry xmlns='http://ift.tt/r5ut6F' xmlns:gsa='http://ift.tt/1vdHDFn'>
<gsa:content name='collectionName'>testcollection</gsa:content>
<gsa:content name='insertMethod''>default</gsa:content>
</entry>


And here is my python:



>> print headers
{'Content-Type': 'application/atom+xml', 'Authorization': 'GoogleLogin auth=googleauthtoken'}
>>> print url
http://GSA_ip:8000/feeds/collection
>>> r = requests.post(url, data=payload, headers=headers, verify=False)

No comments:

Post a Comment