Djoker19 Posted August 29, 2016 Share Posted August 29, 2016 (edited) Hi, I am using pure javascript with Request-Promise to consume the REST API of PrestaShop. I have had success with the GET calls -> Customer List, Product List, Category List, etc. Below is how I am currently consuming the Prestashop REST Service to get response for GET operations let apiUrl = "http://xxxx.com/api/categories/?output_format=JSON"; // Get Categories let apiUrl = "http://xxxx.com/api/products/?output_format=JSON"; // Get Products let options = { method: 'GET', uri: apiUrl, headers: { 'authorization': 'Basic xxxxxxxxx' }, json: true }; return rp(options) .then((res) => { let response = res.categories; return response; }); I want to proceed ahead now with adding a product to the cart. I am not able to find any documentation on how to do it using by calling some REST URL with the required HTTP method and request parameters. Kindly suggest. Thanks & Regards, Kunal Edited August 29, 2016 by Djoker19 (see edit history) Link to comment Share on other sites More sharing options...
Djoker19 Posted August 30, 2016 Author Share Posted August 30, 2016 Below is what I have tried so far using Chrome Advanced REST client URL: http://xxxx.com/api/carts?output_format=JSON POST Raw Headers: authorization: Basic xxxxx Content-Type: application/json Raw Payload: { "cart": { "id": 8, "id_address_delivery": "0", "id_address_invoice": "0", "id_currency": "1", "id_customer": "0", "id_guest": "0", "id_lang": "1", "id_shop_group": "1", "id_shop": "1", "id_carrier": "0", "recyclable": "0", "gift": "0", "gift_message": "", "mobile_theme": "0", "delivery_option": "", "secure_key": "", "allow_seperated_package": "0", "associations": { "cart_rows": [{ "id_product": "4", "id_product_attribute": "16", "id_address_delivery": "0", "quantity": "1", },{ "id_product": "4", "id_product_attribute": "17", "id_address_delivery": "0", "quantity": "1", }] } } } I get response error as below { "errors": [ 1] 0: { "code": null "message": "Internal error. To see this error please display the PHP errors." } - - } Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now