Create New Category from Form Definition

Options
A common development Use Case is to have a form update a category. Most of the time, the Category holding the data is a reflection of the form template +/-.
In the REST API I can easily get the form definition to be used to create a new category. My problem is what would the data definition be for the REST API call to create a new category? 
api/V2/nodes
type: 131
parent id: new_parent_id
Name: new name
Data: {??????}

I did grind through the forums and KB's but did not find anything.

Would anyone have an AJAX snippet for this call and/or the required definition. I assume you would need at least name, type and length.

Cheers,

Ed



Comments


  • In the 20.4 and 16 REST API, I do not see a way to add "leaves" to a Category(131) Object. The maximum I can find is changing the "Applied Category" on a Node.
    Maybe someone from OT REST can say if it exists or not. My guess is it had existed in lapi, it exists now in SOAP(CWS) hence for completeness they may implement it.
    I do not have access to CSIDE but if you have it look in the call that makes that above call and see if you can trace OT doing the rest as you say. There might be indications that it may have been implemented. One way to work around this might be to look at how XMLExport a Category and XMLImport a category. These are two fundamental ways that OT uses a standard XML Out/In. These fundamental aspects you can check yourself by exporting a category to a workbench and import it by transports. the XML Export/Import documentation is freely available in this aspect. It goes against the grain of what you are trying to do in REST but I am just wondering if there is some urgency to your requirement. Have you checked if WR offers the creation of a category,if that is the case you can throw a REST wrapper on it as well? If I was facing this I would have created a custom tag in WR and call it done.



  • Hi Ed,

    Presently manipulating the definition of a category is not available in the REST API. This functionality is an item in our backlog and we'll get to implementing this feature as soon as we can.

    -Jeremy
  • Thanks, no big deal. Just some extra work when building a Form-->Category app.

    I'll investigate some of the options Appu referenced. Bit taken back on his "It goes against the grain of what you are trying to do in REST" comment as it seems like this is the sort of thing most REST API CRUD services were was built for . 

    Cheers,

    Ed


  • That is simple to fix what I meant is if you create a WR workaround pretending it To be a REST endpoint ... instead of a pure clean REST implementation

    I am surprised at why the create category in ReST works what can you do with it after you make one?
  • Time and resources... 
  • Thanks. Would anyone have a sample of WR code that would work or some links.
  • Greg Petti of the original WR group has a blog called @"Greg Petti"

    https://www.ravenblackts.com/blog/using-content-intelligence-for-content-suite-customizations


    Based on code he has put many of us who were originally Oscript programmers could adapt code . I do not know for sure if WR already has a tag to do it but it has an excellent reading mechanism similar to these where you can see the data structure


    https://forums.opentext.com/forums/support/discussion/comment/935131








    Extending REST in Oscript should also not be a huge deal although there is a little bit of ease in the WR way.

    Other swell programmers I have seen

    Christopher Meyer Kwe.li who has a very cool Oscript add on that has rest end points as well .

    I also wrote a category creator based on an excel spreadsheet that used Answer Modules behind the covers.
  • Appu...

    Very intrigued on one of your earlier posts in this thread.

    "That is simple to fix what I meant is if you create a WR workaround pretending it To be a REST endpoint ... instead of a pure clean REST implementation" 

    WR pretending to be a REST endpoint?  This looks very useful. You have any examples or further info on this.

    Cheers,

    Ed


  • Yes if you just go and create a LR , then write a wrapper for that suppose your LR was select top 5 Name from DTRee, you will see 5 names as output to your WR . If you now open postman and run that through regular rest calls for WR it will come out as a JSON response. So that validates that a WR can provide a restful response .

    Now if you have a need to do something that you find otherwise lacking for e.g I don’t know if category/ attributes are allowed to be created manipulated in rest do what does one do

    To create a category in Oscript it may be a very simple affair you can even try to re use the code in the soap api call that is what I do when I am in a hurry and don’t want to completely learn Oscript methods so I would grab that code and create a WR Tag (custom) . Once it is there you can do whatever you need to do

    Now this is something moot if one knows Oscript it is very easy to add calls to REST as well as it is in fact a specialized request handler which every starting Oscript et learns:)
  • Thanks, not an Oscript guy.  I would like to give it a try. How would you script the POSTMAN call for your example , you would have the endpoint, but what else do you need. 
  • I am not a REST programmer per se but I use POSTman and I then take its code suggestions and convert it into workable code(java,.Net etc) in a recent integration I had to call a WR from another place for which I used this technique

    https://knowledge.opentext.com/knowledge/cs.dll/Properties/78166290
  • The WebReport Rest API docs are here: https://developer.opentext.com/apis/1e147950-773d-49d2-b2d4-7dde2d21698e/Content%20Server%2020.4%20REST%20API#operation/getWebReportOutput

    If you want to return structured data based on what is in the data source it's easiest to return JSON using the INSERTJSON tag. Although the Rest API just returns the text output of the WebReport so other approaches can be used. The content type is defined by what is set in the WebReport output destination mime type field.
  • Very helpful, thanks