-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCode.gs
41 lines (34 loc) · 1.06 KB
/
Code.gs
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
function onFormSubmit(e) {
const formResponse = e.response;
const itemResponses = formResponse.getItemResponses();
const data = {};
itemResponses.forEach((itemResponse) => {
const title = itemResponse.getItem().getTitle();
let response;
if (title == 'Foto de Identificação') {
response = DriveApp.getFileById(itemResponse.getResponse()[0]).getDownloadUrl();
} else {
response = itemResponse.getResponse();
}
if (title == 'Nome Completo') {
data['name'] = response;
} else if (title == 'Matrícula') {
data['id'] = response;
} else if (title == 'Foto de Identificação') {
data['picUrl'] = response;
}
});
data['email'] = formResponse.getRespondentEmail()
const headers = {
Authorization: "Bearer <Token>"
}
const options = {
headers: headers,
method: 'POST',
contentType: 'application/json',
payload: JSON.stringify(data),
};
const url = 'http://<HOST>/students';
const response = UrlFetchApp.fetch(url, options);
console.log(response.getResponseCode());
}