Adam Morris | IT Systems & English Teacher | IGB International School
Jalan Sierramas Utama, Sierramas,
47000 Sungai Buloh, Selangor DE, Malaysia
t +60 3 6145 4688
f +60 3 6145 4600
w www.igbis.edu.my
e adam....@igbis.edu.my
--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-script-community.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/c1ced315-2feb-445f-ac9b-15e09f130a0d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-community+unsub...@googlegroups.com.
function avmatest(){ var testurl = 'https://avmajournals.avma.org/reports/tr_j1?customer_id=175152&requestor_id=colle...@upei.ca&begin_date=2019-01&end_date=2019-04&'; // get the cookie var cookie = UrlFetchApp.fetch(testurl).getAllHeaders()['Set-Cookie']; // use the cookie provided var options = {"headers":{ cookie: cookie}}; var response = UrlFetchApp.fetch(encodeURI(testurl), options);
var content = response.getContentText(); Logger.log(testurl);
Logger.log(JSON.parse(response.getContentText())); }
Можно на Русском языке ?
That solved it, thank you very much!
On Thursday, June 6, 2019 at 4:21:48 PM UTC-3, Martin Hawksey wrote:
Looks like the server needs to see a cookie before it will server JSON. The modified code below makes a call to get the cookie from the header response and then uses it in the next call:
function avmatest(){
Here's the function I'm using to test it and looking at the View-Logs to see the output:
function avmatest(){
var response = UrlFetchApp.fetch(encodeURI(testurl, { muteHttpExceptions: true }));var content = response.getContentText();Logger.log(testurl);Logger.log(content.substring(0,500));}You can paste the URL directly into your browser and see the JSON. Then put the function in a script file and see that you get back something else entirely.
--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-community+unsubs...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-script-community.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/c1ced315-2feb-445f-ac9b-15e09f130a0d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-community+unsub...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-script-community.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/dde1e54c-ec74-4854-b8f3-d903aa5a65dd%40googlegroups.com.