Gets a specific message using format=minimal.
LOCAL loRest
LOCAL lnSuccess
LOCAL loOauth2
LOCAL loSbJson
LOCAL loJson
LOCAL lcId
LOCAL lcThreadId
LOCAL lcSnippet
LOCAL lcHistoryId
LOCAL lcInternalDate
LOCAL lnSizeEstimate
LOCAL i
LOCAL lnCount_i
LOCAL lcStrVal
loRest = CreateObject('Chilkat_9_5_0.Rest')
* Provide a previously obtained OAuth2 access token.
loOauth2 = CreateObject('Chilkat_9_5_0.OAuth2')
loOauth2.AccessToken = "OAUTH2_ACCESS_TOKEN"
loRest.SetAuthOAuth2(loOauth2)
lnSuccess = loRest.Connect("www.googleapis.com",443,1,1)
IF (lnSuccess <> 1) THEN
? loRest.LastErrorText
RELEASE loRest
RELEASE loOauth2
CANCEL
ENDIF
loRest.AddPathParam("messageId","15fc237e79da4174")
loRest.AddQueryParam("format","minimal")
loSbJson = CreateObject('Chilkat_9_5_0.StringBuilder')
lnSuccess = loRest.FullRequestNoBodySb("GET","/gmail/v1/users/me/messages/messageId",loSbJson)
IF (lnSuccess <> 1) THEN
? loRest.LastErrorText
RELEASE loRest
RELEASE loOauth2
RELEASE loSbJson
CANCEL
ENDIF
IF (loRest.ResponseStatusCode <> 200) THEN
? "Received error response code: " + STR(loRest.ResponseStatusCode)
? "Response body:"
? loSbJson.GetAsString()
RELEASE loRest
RELEASE loOauth2
RELEASE loSbJson
CANCEL
ENDIF
loJson = CreateObject('Chilkat_9_5_0.JsonObject')
loJson.LoadSb(loSbJson)
* The following code parses the JSON response.
* A sample JSON response is shown below the sample code.
lcId = loJson.StringOf("id")
lcThreadId = loJson.StringOf("threadId")
lcSnippet = loJson.StringOf("snippet")
lcHistoryId = loJson.StringOf("historyId")
lcInternalDate = loJson.StringOf("internalDate")
lnSizeEstimate = loJson.IntOf("sizeEstimate")
i = 0
lnCount_i = loJson.SizeOfArray("labelIds")
DO WHILE i < lnCount_i
loJson.I = i
lcStrVal = loJson.StringOf("labelIds[i]")
i = i + 1
ENDDO
? "Example Completed."
RELEASE loRest
RELEASE loOauth2
RELEASE loSbJson
RELEASE loJson
{
"id": "15fc237e79da4174",
"threadId": "15fc237e79da4174",
"labelIds": [
"IMPORTANT",
"SENT",
"INBOX"
],
"snippet": "This is a test email with 2 attachments.",
"historyId": "1582",
"internalDate": "1510791964000",
"sizeEstimate": 11153
}