Creating Category using WebAPI


https://forum.kartris.com/Topic2533.aspx
Print Topic | Close Window

By Boxson - Wed 30 Oct 2013
Hi,

i'm trying to connect Kartirs to our base system. Therefore i need to sync the categories to kartris. I try that using the WebAPI.

For creating new Categories i utilize the method "CategoriesBLL._Add".

Is it possible to get the CAT_ID of a newly created Category via WebAPI? I need to build parent-/child relations during sync. Therefore i need to know the ID of a created Category in Kartris. Additional i need to store the CAT_ID of a Kartris Category in my Base System for later sync (modification, deletion of category in base system and so on.)

I tried to search for a created category with "CategoriesBLL.SearchCategoryByName", but this method returns all Categories that have the search-team in it and the Category-title in this case had to be unique.
By Medz - Thu 31 Oct 2013
The WebAPI only outputs the value returned by the called function at the moment. It doesn't work very well with ones that have ByRef parameters as you can't retrieve the value passed to those variables through an API call. In your case, the _AddCategory uses the pCategoryID ByRef parameter to return the newly created category ID to the user. At the moment, you'll only be able to get the boolean value that the function returns.

A way of accomplishing this (get CAT ID) for now is by modifying CategoriesBLL and adding a custom AddCategory function there that returns the PCategoryID instead of a boolean value. You can just duplicate and rename the existing _AddCategory function and modify the copy according to your needs. The WebAPI is flexible enough that custom functions can also be accessed through it the same as the standard ones.
By Boxson - Thu 31 Oct 2013
Thanks for the answer,

i'll try that. I tried to Create a Category. Therefore i need to hand over some data as a "DataTable" to the Method _AddCategory. This needs to be parsed as XML additional to the other params within the strParametersXML string.

Do you - or somebody else - have kind of an example how the xml has to look like? If i send a dataTable as xml, i only recieve the result

<?xml version="1.0" encoding="utf-16"?><string>Error parsing method string! Exception Details -&gt; Error in XML-Document (1,1).".


I'm stuck with this for hours now. Without any information how the webservice data needs to be sent it is "try and error"...

BoXson
By Boxson - Wed 6 Nov 2013
See here: http://forum.kartris.com/Topic2547.aspx