When debugging an external host connection, UrlFetchAppseveral tools are available.
muteHttpExceptions, . (, , , throw , .)
'muteHttpExceptions' : true fetch.
, fetch , HTTPResponse. ( ).
, :
var response = UrlFetchApp.fetch(url, options);
var rc = response.getResponseCode();
if (rc !== 200) {
Logger.log("Response (%s) %s",
rc,
response.getContentText() );
}
, :
[15-08-27 11:18:06:688 EDT] Response (404.0) {
"error": true,
"message": "Could not find API"
}
API- . , . , URL, API, . , , .
fetch, getRequest(). fetch() fetch().
var test = UrlFetchApp.getRequest(url, options);
, , test.
POST. # %23 JSON.stringify(), .
, , contentType 'application/json'.

, , contentType content-Type. .
, .
- encodeURIComponent(), fetch, . , "" , # UTF-8, %23.
:
function PostParameters2() {
var parameters = {
apikey: "--apikey--",
urls: [
encodeURIComponent("https://twitter.com/search?q=#running"),
encodeURIComponent("https://twitter.com/search?q=#swimming")
]
};
var data = JSON.stringify(parameters);
var url = 'https://kimonolabs.com/kimonoapis/--apiId--/update';
var options = {
'method': 'POST',
'contentType': 'application/json',
'payload': data,
'muteHttpExceptions' : true
};
var test = UrlFetchApp.getRequest(url, options);
var response = UrlFetchApp.fetch(url, options);
var rc = response.getResponseCode();
if (rc !== 200) {
Logger.log("Response (%s) %s",
rc,
response.getContentText() );
}
else {
var responseText = response.getContentText();
Logger.log(responseText);
}
}