fsandovalsk Posted May 19 Share Posted May 19 Hello, Can't connect to Loyverse API with Google Script. Same info works fine with Postman. GOOGLE SCRIPT function loyverseJSON() { var url = "https://api.loyverse.com/v1.0/receipts"; var options = { "Method": "get", "Headers": { "Accept": "application/json", "Content-Type": "application/json", "Authorization": "Bearer XXXXXXXXXXXXXXXXXXXXXXXXXXXXX" }, "Body": { "created_at_min" : "2023-05-18T00:00:00.000Z", "limit" : 20 } } var response = UrlFetchApp.fetch(url, options); Logger.log(response); } ERROR Exception: Request failed for https://api.loyverse.com returned code 401. Truncated server response: {"errors":[{"code":"UNAUTHORIZED","details":"Access token is not valid."}]} Thanks Link to comment Share on other sites More sharing options...
Yasuaki Posted May 22 Share Posted May 22 Hello. Could you check if your access token is correct or not expired? Link to comment Share on other sites More sharing options...
fsandovalsk Posted May 24 Author Share Posted May 24 Hello, access token not expired. Added another and both don't work. Postman works fine. Link to comment Share on other sites More sharing options...
fsandovalsk Posted May 26 Author Share Posted May 26 (edited) Thanks Ki this works! function loyverseJSON() { var url = "https://api.loyverse.com/v1.0/receipts?created_at_min=2023-05-26T00:00:00.000Z&limit=2"; var options = { "method": "get", //<- "headers": //<- { "Accept": "application/json", "Content-Type": "application/json", "Authorization": "Bearer XXXXXXXXXXXXXXXXXXXXXXXX" } } var response = UrlFetchApp.fetch(url, options); Logger.log(response); } Edited May 26 by fsandovalsk Link to comment Share on other sites More sharing options...
Yasuaki Posted May 29 Share Posted May 29 That's great to hear! Link to comment Share on other sites More sharing options...
Recommended Posts