Code Generator for HTTP Requests

Generate ”ready to run“ code snippets for making HTTP requests with Google Apps Script, JavaScript, Node.js and cURL commands.

function makePostRequest() {
	const url = "https://postman-echo.com/post?source=web&foo=bar";
	const response = UrlFetchApp.fetch(url, {
		"method": "POST",
		"headers": {
			"x-api-key": "123xyz",
			"cache-control": "no-cache",
			"Content-Type": "application/x-www-form-urlencoded"
		},
		"muteHttpExceptions": true,
		"followRedirects": true,
		"validateHttpsCertificates": true,
		"contentType": "application/x-www-form-urlencoded",
		"payload": "name=Amit%20Agarwal&title=Google%20Developer%20Expert"
	});

	Logger.log("Response code is %s", response.getResponseCode());
	Logger.log(response.getContentText());
}