forked from paymo-org/api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpost.gs
More file actions
30 lines (24 loc) · 791 Bytes
/
Copy pathpost.gs
File metadata and controls
30 lines (24 loc) · 791 Bytes
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
function samplePostRequest() {
const email = 'johndoe@email.com';
const password = 'secret';
var headers = {
"Authorization": "Basic " + Utilities.base64Encode(email + ":" + password),
"Accept": "application/json",
"Content-type": "application/json"
};
var postData = {
client_id: 123456,
name: 'New Project',
description: 'Project added from API'
};
var params = {
"method": "POST",
"headers": headers,
"payload": JSON.stringify(postData)
};
var url = "https://app.paymoapp.com/api/projects";
var response = UrlFetchApp.fetch(url, params);
Logger.log("response code: " + response.getResponseCode());
var responseJson = JSON.parse(response.getContentText());
Logger.log("New Project ID: " + responseJson.projects[0].id);
}