Gets a specific message using format=minimal.
var os = require('os');
if (os.platform() == 'win32') {
var chilkat = require('chilkat_node6_win32');
} else if (os.platform() == 'linux') {
if (os.arch() == 'arm') {
var chilkat = require('chilkat_node6_arm');
} else if (os.arch() == 'x86') {
var chilkat = require('chilkat_node6_linux32');
} else {
var chilkat = require('chilkat_node6_linux64');
}
} else if (os.platform() == 'darwin') {
var chilkat = require('chilkat_node6_macosx');
}
function chilkatExample() {
var rest = new chilkat.Rest();
var success;
// Provide a previously obtained OAuth2 access token.
var oauth2 = new chilkat.OAuth2();
oauth2.AccessToken = "OAUTH2_ACCESS_TOKEN";
rest.SetAuthOAuth2(oauth2);
success = rest.Connect("www.googleapis.com",443,true,true);
if (success !== true) {
console.log(rest.LastErrorText);
return;
}
rest.AddPathParam("messageId","15fc237e79da4174");
rest.AddQueryParam("format","minimal");
var sbJson = new chilkat.StringBuilder();
success = rest.FullRequestNoBodySb("GET","/gmail/v1/users/me/messages/messageId",sbJson);
if (success !== true) {
console.log(rest.LastErrorText);
return;
}
if (rest.ResponseStatusCode !== 200) {
console.log("Received error response code: " + rest.ResponseStatusCode);
console.log("Response body:");
console.log(sbJson.GetAsString());
return;
}
var json = new chilkat.JsonObject();
json.LoadSb(sbJson);
// The following code parses the JSON response.
// A sample JSON response is shown below the sample code.
var id;
var threadId;
var snippet;
var historyId;
var internalDate;
var sizeEstimate;
var i;
var count_i;
var strVal;
id = json.StringOf("id");
threadId = json.StringOf("threadId");
snippet = json.StringOf("snippet");
historyId = json.StringOf("historyId");
internalDate = json.StringOf("internalDate");
sizeEstimate = json.IntOf("sizeEstimate");
i = 0;
count_i = json.SizeOfArray("labelIds");
while (i < count_i) {
json.I = i;
strVal = json.StringOf("labelIds[i]");
i = i+1;
}
console.log("Example Completed.");
}
chilkatExample();
{
"id": "15fc237e79da4174",
"threadId": "15fc237e79da4174",
"labelIds": [
"IMPORTANT",
"SENT",
"INBOX"
],
"snippet": "This is a test email with 2 attachments.",
"historyId": "1582",
"internalDate": "1510791964000",
"sizeEstimate": 11153
}