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

Load Balancing in Bluemix using custom domain and DNS SRV records -

oracle - pls-00402 alias required in select list of cursor to avoid duplicate column names -

python - Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] error -