A quick guide to develop a PrestaShop mobile app.

prestashop mobile app

We provide solutions to the client by building apps according to their requirements. We developed many apps on many different frameworks like SocialEngine, Magento, Woocommerce etc. Recently we got a new project from one of our clients. Their requirement was to develop an e-commerce app for their e-store which was on PrestaShop platform. Prestashop is a free open-source e-commerce solution. So the point was we have to build PrestaShop mobile app for their store using web-services.

As PrestaShop REST API was new for us and we knew that we would get problems during our implementation, but it would start at the first step was not expected 🙁 . We started the implementation and the first problem that we faced was how to build Prestashop mobile app. We can also say it as how to access Prestashop Webservice. Every time we hit the API , it gave “401 Unauthorized” and message “The server says welcome to Prestashop Webservice, please enter the authentication key as login. No password required”.
We did a lot of research, googled it, also found some solutions like – use the API key (The API key serves as the main identifier for the web service account you are creating) at the start of the URL

       http://[email protected]/

but every approach was fruitless. We tried every possible method to send the API Key with URL so that it can authorise the web service but nothing happened. The main confusing point was when we were hitting the URL directly on the browser by putting API Key at the start of URL it was working. Then after working several hours we found the solution. Before describing the solution I would like to list some essential points need to work on while accessing Prestashop Webservice :

Points to revisit before you start to build PrestaShop mobile app.

  1. Authentication key : This the most important key. Using this API key, the selected users will be able to access the web service. This key is provided by the server side. It is needed to send with the API.
  2. Permission for Resources : This is very important, as it enables the resources you want to make available to your user. These permissions are enabled from the server side.

To build Prestashop mobile app first you have to access its Webservice, so, you need to provide your authentication key or API key when request. No password is required only API key is enough for accessing the API. Now here, the problem is how to pass this API key with your request because if you will not provide this key it will not allow you to access Prestashop Webservice. The solution is while accessing the API from the mobile you need to pass this key in the header as BASIC AUTH.

When we add API Key with URL, Browsers are intelligent enough to understand it as username but the mobile web-services are not. So we need to pass it by building BASIC AUTH. We pass API Key as username and leave password blank as shown in below example:

     Request request = chain.request();
     String credential = Credentials.basic(Constants.API_KEY, "");
     request = request.newBuilder().header("Authorization", credential).build();

Conclusion

The above-explained solution can help many developers to start PrestaShop mobile app with its web-services. Giant eCommerce companies are now focusing on improving end-user experience on mobile devices. They are providing a strong technology infrastructure via cutting-edge mobile applications. Prestashop is one of the popular eCommerce open-source platforms and it has taken an important place in the eCommerce market for developing e-store. Using Prestashop API for e-store can be proved to be an intelligent option.You can also browse other apps already developed with Prestashop Webservices for example- PrestaShopee ,Prestashop mobile. If you need any help and assistance regarding app, website etc. development feel free to contact us.

References

Prestashop is a free open-source which provides the solution for e-commerce. For more information, you can visit the following link PrestaShop.

PrestaShop provides documentation for the list of all basic APIs that  are needed for the e-store.To get more details about the documentation you can visit this link PrestaShop Webservice

 

A quick guide to develop a PrestaShop mobile app. was last modified: August 3rd, 2016 by Neha Prakash