-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathGS_HTTPS_Request.gs
More file actions
69 lines (54 loc) · 1.52 KB
/
Copy pathGS_HTTPS_Request.gs
File metadata and controls
69 lines (54 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
var fetcha = (function(po) {
'use strict';
// this is namespace object
var lkcmvaowperuy = {};
// a function in this namespace
lkcmvaowperuy.fetch_ = function (po) {
Logger.log('fetch_ ran')
var e, payload, options,r,res,w,url;
if (!po.url) {
errHndl_(undefined,'vnhoa8rylfihads','There is no URL for the HTTPS Request')
return false;
}
url = po.url;
options = {};
options.muteHttpExceptions = false;//Always set to true
if (po.contentType) {
options.contentType = po.contentType;
}
if (po.headers) {
options.headers = po.headers;
}
if (po.payload) {
options.payload = po.payload;
}
options.method = po.method;
try {
if (options.headers != null) {
options.headers["User-Agent"] = "Mozilla/5.0 Firefox/26.0";
}
Logger.log('url: ' + url)
Logger.log('options: ' + options)
res = UrlFetchApp.fetch(url, options);
Logger.log('res: ' + res)
} catch (e) {
Logger.log('e.message: ' + e.message)
errHndl_(e,'lkcmvaowperuy.fetch_','Error making HTTPS request')
}
try {
r = JSON.parse(res.getContentText());
} catch (e) {
}
return r;
};
return lkcmvaowperuy;
})();
function testIt() {
var rtrn;
var po = {
'url':'www.google.com',
'method':'get'
}
rtrn = fetcha.fetch_(po);
Logger.log(rtrn)
}