View Single Post
  #1  
Old 06-07-2018, 01:43 PM
 
rstubbe rstubbe is offline
 

Member
  
Join Date: Nov 2005
Posts: 14
 

Default REST API Create new Category

I am trying to add a category via the REST API, but every attempt seem to fail with an error 400 or a success, but then the consistency check fails.

What I do is the following:
POST http://localhost/xcart5/admin.php?target=RESTAPI&_key=mykey&_path=category /0
with data:
{"depth":0,"pos":0,"translations":[{"code":"nl","name":"ALBUM & LIJST"},{"code":"en","name":"ALBUM & LIJST"}]}

It will give me the Success but actually creates a second root causing the consistancy check to fail.

When I change the data to:
{"depth":0,"pos":0,"translations":[{"code":"nl","name":"ALBUM & LIJST"},{"code":"en","name":"ALBUM & LIJST"}],parent:{"ogMeta":"","useCustomOG":false,"demo":fa lse,"useClasses":"A","category_id":1,"lpos":1,"rpo s":4,"enabled":true,"show_title":false,"depth": -1,"pos":0,"root_category_look":"icons","metaDescTy pe":"A","xcPendingExport":false,"lastUsage":0}}

Basicly adding the parent it will give me an error 400 Input data is incorrect

I also tried with specifying rpos/lpos, but it keeps on failing.

Can someone give me a working example?
__________________
Ronald Stubbe
X-Cart 4.1.4
Reply With Quote