google apps script - Invalid Argument on basic API call using UrlFetchApp.fetch(url) -


i'm new google apps scripts , i've been trying make simple call url. make call browser: https://accounting.sageone.co.za/api/1.1.1/supplier/get?apikey={4cfeefe1-ce04-425f-82c3-dcb179c817d5}&companyid=164740 , respons i'm looking for. try make call google apps scripts using following code:

function myfunction() { var url = 'https://accounting.sageone.co.za/api/1.1.1/supplier/get?apikey={4cfeefe1-ce04-425f-82c3-dcb179c817d5}&companyid=164740 var response = urlfetchapp.fetch(url); logger.log(response); }' 

i respons stating ' message details invalid argument: https://accounting.sageone.co.za/api/1.1.1/supplier/get?apikey={4cfeefe1-ce04-425f-82c3-dcb179c817d5}&companyid=164740 (line 4, file "code")'

i've tried whole bunch of permutations no luck...

when using urlfetchapp, need enter url parameters part of request parameters rather in url itself. get request these go directy part of parameters, post request parameters part of payload object. reference documentation

here modified function:

function myfunction() {   var url = 'https://accounting.sageone.co.za/api/1.1.1/supplier/get'     var params = {     "method": 'get',     "apikey": "{4cfeefe1-ce04-425f-82c3-dcb179c817d5}",     "companyid": "164740"   }   var response = urlfetchapp.fetch(url, params);   logger.log(response) } 

note: corrects method, however, server still requires further authentication. if run issues that, ask questions specific issue well.


Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -