Jump to content

Prestashop webservices and Google Sheet script integration


Recommended Posts

I am trying to implement basic Google sheet script to retrieve customers list using Prestashop webservices :

  var URL_STRING = "https://www.mydomain.com/api/customers?display=[firstname,lastname,email]";
  
  var response = UrlFetchApp.fetch(URL_STRING);
  var json = response.getContentText();
  var data = JSON.parse(json);

Very logically, this script is not working because I do not mention the authentication KEY, so I go the reply "401 Unauthorized".

So I have tried to insert the KEY in the URL, like this :

  var URL_STRING = "https://[email protected]/api/customers?display=[firstname,lastname,email]";
  
  var response = UrlFetchApp.fetch(URL_STRING);
  var json = response.getContentText();
  var data = JSON.parse(json);

But it is not working as well (reply "401 Unauthorized").

What should I do to mention the KEY in the code and make the script working correctly ?

Thank you 🙂

Link to comment
Share on other sites

12 minutes ago, 4you.software said:

Hi.

Your api url?ws_key=ABCDEF

Thank you. I have tried this code :

var URL_STRING = "https://www.mydomain.com/api/customers?ws_key=KEY";
  
  var response = UrlFetchApp.fetch(URL_STRING);
  var json = response.getContentText();
  var data = JSON.parse(json);

And I got the error :

SyntaxError: Unexpected token < in JSON at position 0

🙁

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...