php - prestashop create and update resources via url webservice api -


i (unfortunately) have write client application front end prestashop powered web site. i'd need perform crud operations on resources via url webservice , i'm stuck on create , update. surprise find out how few examples available on web since prestashop supposed used cms. however, till came to:

get http://www.myshop.com/api/myresource/id 

to xml resource given id or

get http://www.myshop.com/api/myresource/?display=full&filter[field]=[value] 

to filter results. i'm writing because had struggle google achieve information, filters stuff might in future.

delete http://www.myshop.com/api/myresource/id 

to delete resource (i suppose filters work here too, didn't try far)

now, know how create , update resources? tried

post/put http://www.myshop.com/api/myresource/ 

giving couples of field - value in http request parameters no luck, i'm getting internal server error. no, have no direct access server don't know error thrown , hope can solved without bother website maintainers, i'd save ammunitions.

the useful resource found on web this one, looked among other question on , suggested links in question of no help.

if edit config/config.inc.php , add following able see errors in response (error) (1by1 frustrating when trying work out why create fails). remember comment out line when done.

/*debugging on*/ ini_set('display_errors', 'on');  

you need make sure prepend data in post/put operation xml=<prestashop>......</prestashop> (i using c# client may not required php)

if using ?schema=synopsis blank one, make sure go through elements in xml in there placeholders , remove them.. (products) example broken kind of work if don't.

i added code in initial pass of xml walks tree, looking attribute not_filterable , removes nodes (once again not documentation available know if right thing do).

edit: 1 other thing of note in , of language based elements, make sure using cdata elements.

i have succeeded generating products via performing hope it's of help. yet perform update of existing.

update: have since updated 1.5.4.1 of prestashop , started updating resource products in case

update resource

uri: http://site/api/products/1

use method = "put"

content type = "text/xml"

make sure remove elements have 'not_filterable' attribute set. (i don't understand why, doesn't work if don't)

delete resource

uri: http://site/api/products/1

use method = "delete"

content type = "application/x-www-form-urlencoded"

i found don't need body can set contentlength 0 seems. , probaly don't need content type set either, works.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -