From: Greg P. <gp...@gm...> - 2011-09-29 23:45:49
|
Ross - I've been troubleshooting my use of the OpenNMS REST API in the past few days, and found it very useful to use provision.pl to do what I was trying to do and look at packet captures to see exactly what was going on. Maybe that can be of some use to you as well? Greg On Fri, Jul 15, 2011 at 6:58 AM, Ross McKerchar <Ros...@so...>wrote: > Hi All, > > I took a guess and found posting the content '<category name="foo"/>' to > "/nodes/<nodeid>/categories" with the header 'Content-type': > 'application/xml' works. You can omit the ID attribute, appears to get > filled out automatically (guessing it's a db key). > > I'd still appreciate a little more info on this, if anyone has played with > it more extensively. > > -ross > > -----Original Message----- > From: Ross McKerchar [mailto:Ros...@so...] > Sent: 15 July 2011 11:59 > To: ope...@li... > Subject: [opennms-discuss] Using the RESTful api to modify node categories > > Hi All, > > I'm struggling to modify node categories using the RESTful api. > > The documentation @ http://www.opennms.org/wiki/ReST indicates: > POST: /nodes/{id}/categories Add a category association to the node. > (POST requires XML using application/xml as its Content-Type.) > PUTs: /nodes/{id}/categories/{categoryName} Modify the category with > the given node ID and name. (PUT requires form data using > application/x-www-form-urlencoded as a Content-Type.) > > However, I can't translate the above into a working http POST/PUT request > to add the tag "foo" to a node. > > For POST, it's not clear how I structure the XML, particularly looking at > the XML retrieved via a node GET I see: <categories name="foo" > id="24"/><categories name="bar" id="13"/> but it's not clear what the ID > attribute is for? For the PUT, I don't understand what form data to submit - > given the category is referenced in the URL I don't understand what other > data I need to stick in my urlencoded request. > > Has anyone got some example code to fiddle with categories via the REST api > that could help me understand this a little more? > > Thanks, > > -ross > > > Sophos Limited, The Pentagon, Abingdon Science Park, Abingdon, OX14 3YP, > United Kingdom. > Company Reg No 2096520. VAT Reg No GB 991 2418 08. > > > ------------------------------------------------------------------------------ > AppSumo Presents a FREE Video for the SourceForge Community by Eric Ries, > the creator of the Lean Startup Methodology on "Lean Startup Secrets > Revealed." This video shows you how to validate your ideas, optimize your > ideas and identify your business strategy. > http://p.sf.net/sfu/appsumosfdev2dev > _______________________________________________ > Please read the OpenNMS Mailing List FAQ: > http://www.opennms.org/index.php/Mailing_List_FAQ > > opennms-discuss mailing list > > To *unsubscribe* or change your subscription options, see the bottom of > this page: > https://lists.sourceforge.net/lists/listinfo/opennms-discuss > > Sophos Limited, The Pentagon, Abingdon Science Park, Abingdon, OX14 3YP, > United Kingdom. > Company Reg No 2096520. VAT Reg No GB 991 2418 08. > > > ------------------------------------------------------------------------------ > AppSumo Presents a FREE Video for the SourceForge Community by Eric > Ries, the creator of the Lean Startup Methodology on "Lean Startup > Secrets Revealed." This video shows you how to validate your ideas, > optimize your ideas and identify your business strategy. > http://p.sf.net/sfu/appsumosfdev2dev > _______________________________________________ > Please read the OpenNMS Mailing List FAQ: > http://www.opennms.org/index.php/Mailing_List_FAQ > > opennms-discuss mailing list > > To *unsubscribe* or change your subscription options, see the bottom of > this page: > https://lists.sourceforge.net/lists/listinfo/opennms-discuss > |