ERPNext with Google App Script

I’m tryng to integrate ERPNext with google app sctipts using Frappe RESTful API.
Here is the code:

// Log In.
var options = {
‘method’ : ‘POST’,
‘contentType’: ‘application/json’
};
var response=UrlFetchApp.fetch(‘https://demo.erpnext.com/api/method/login?usr=demo@erpnext.com&pwd=demo’, options);
var data=JSON.parse(response)
Logger.log(data.full_name);

// Get Employes
var options = {
‘method’ : ‘GET’,
‘contentType’: ‘application/json’
};
var response=UrlFetchApp.fetch(‘https://demo.erpnext.com/api/resource/Employee’, options);
Logger.log(response.getContentText());

The login works fine but the Employee search Return an error 403.

I test both commands from POSTMAN and works without problem.

Does the user have permissions to Employee?

Yes, it works with POSTMAN.

I found this, and works for me.

1 Like