Jotadrive Posted October 27, 2020 Share Posted October 27, 2020 Hi fellas, I am developing a mobile app in flutter which makes request to Prestashop API. I noticed I can't make JSON POST requests (or I couldn't find it). Should I build a custom API in Prestashop to do this kind of request ("Create order", "Create cart", etc...)? Thanks Link to comment Share on other sites More sharing options...
Zohaib-fk Posted October 28, 2020 Share Posted October 28, 2020 I have developed a video tutorial regarding "how to configure and use web services" I hope it will help. Link to comment Share on other sites More sharing options...
Jotadrive Posted October 28, 2020 Author Share Posted October 28, 2020 Hi mate, Thank you very much, but in the video you just showed how to do GET request, and not in JSON, in XML... so I still have the problem. Thanks Link to comment Share on other sites More sharing options...
rrataj Posted October 28, 2020 Share Posted October 28, 2020 Hey! Could you please provide more details: - What is you stack for prestashop (web server, php?) - how do you make POST requests? (in postman or in flutter directly) - what do you get in response? (header and content) Link to comment Share on other sites More sharing options...
Jotadrive Posted October 28, 2020 Author Share Posted October 28, 2020 Hi rrataj, I am using a simple Prestashop store with Webservices enabled, so I can make GET request and all works fine. First of all I am using Postman to do this request, but finally I would like to integrate it on flutter. I would like to do requests as "Create order, Create cart, Create user" and other POST request via JSON (if it's possible, XML if not). I haven't done POST request before because I don't know which parameters should I include, format, etc... I would appreciate your help if you have experience with this API. Thanks a lot Link to comment Share on other sites More sharing options...
rrataj Posted October 28, 2020 Share Posted October 28, 2020 Sorry, I only used XML with PHP lib for this. Maybe after reading this you will be able to understand more: https://devdocs.prestashop.com/1.7/webservice/tutorials/prestashop-webservice-lib/create-resource/ Link to comment Share on other sites More sharing options...
Jotadrive Posted October 28, 2020 Author Share Posted October 28, 2020 Thanks a lot mate, this helped me Link to comment Share on other sites More sharing options...
Jotadrive Posted October 28, 2020 Author Share Posted October 28, 2020 But mate, is it possible to do XML request with this format via Postman? Thanks Link to comment Share on other sites More sharing options...
rrataj Posted October 28, 2020 Share Posted October 28, 2020 I'm not sure, because you need to first do GET to receive blank schema, then fill it and after that you need to do a POST to actually create an object as far as I understand. Link to comment Share on other sites More sharing options...
Surffari Posted October 29, 2020 Share Posted October 29, 2020 Hi all, My fullfilment partner is using the WS API to retrieve the orders, updte stock and change order status. They are also pushing the tracking code to my shop. However, the tracking has now started appearing with a strange suffix. The fulfilment partner now claims Presta instance (gopure.shop) is adding this suffix and I'm sure this is coming from their end. My question: Is there a way/log to see the content of the WS requests they are sending. I checked the logs presta saves to DB and nothing there. Also found the server logs where I can find for example GET/PUT requests originating from their server like these: xx.xx.xx.xx - - [06/Oct/2020:06:00:45 +0200] "PUT /api/stock_availables/242 HTTP/1.1" 200 660 "-" "-" xx.xx.xx.xx - - [06/Oct/2020:06:00:46 +0200] "GET /api/stock_availables?filter%5Bid_product%5D=xx&filter%5Bid_product_attribute%5D=xxx&display=full HTTP/1.1" 200 699 "-" "-" Is there a log or way to see what data their requests contain? Or do I need to use some kind of net traffic sniffer? Link to comment Share on other sites More sharing options...
rrataj Posted October 29, 2020 Share Posted October 29, 2020 I would try to override "classes/webservice/WebserviceRequest.php" Class and "fetch()" method and do something like: public function fetch($key, $method, $url, $params, $bad_class_name, $inputXml = null) { // save to logs if( !empty( inputXml ) ) { PrestaShopLogger::addLog('Webservice input:' . $inputXml); } // call parent controller return parent::fetch($key, $method, $url, $params, $bad_class_name, $inputXml) } But haven't tested it. Link to comment Share on other sites More sharing options...
binshops Posted July 17, 2021 Share Posted July 17, 2021 Hi guys, you can also use our REST API module to develop any modern client-side application: https://addons.prestashop.com/en/website-performance/52062-binshops-rest-api.html#specifications There is no need to setup webservice APIs and no need for any token. After installation everything is ready. Try it out. 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