Generates a set of file IDs which can be provided in create requests.
#include <C_CkRestW.h>
#include <C_CkOAuth2W.h>
#include <C_CkStringBuilderW.h>
#include <C_CkJsonObjectW.h>
void ChilkatSample(void)
{
HCkRestW rest;
BOOL success;
HCkOAuth2W oauth2;
HCkStringBuilderW sbJson;
HCkJsonObjectW json;
const wchar_t *kind;
const wchar_t *space;
int i;
int count_i;
const wchar_t *strVal;
rest = CkRestW_Create();
// Provide a previously obtained OAuth2 access token.
oauth2 = CkOAuth2W_Create();
CkOAuth2W_putAccessToken(oauth2,L"OAUTH2_ACCESS_TOKEN");
CkRestW_SetAuthOAuth2(rest,oauth2);
success = CkRestW_Connect(rest,L"www.googleapis.com",443,TRUE,TRUE);
if (success != TRUE) {
wprintf(L"%s\n",CkRestW_lastErrorText(rest));
CkRestW_Dispose(rest);
CkOAuth2W_Dispose(oauth2);
return;
}
CkRestW_AddQueryParam(rest,L"count",L"20");
CkRestW_AddQueryParam(rest,L"space",L"drive");
sbJson = CkStringBuilderW_Create();
success = CkRestW_FullRequestNoBodySb(rest,L"GET",L"/drive/v3/files/generateIds",sbJson);
if (success != TRUE) {
wprintf(L"%s\n",CkRestW_lastErrorText(rest));
CkRestW_Dispose(rest);
CkOAuth2W_Dispose(oauth2);
CkStringBuilderW_Dispose(sbJson);
return;
}
if (CkRestW_getResponseStatusCode(rest) != 200) {
wprintf(L"Received error response code: %d\n",CkRestW_getResponseStatusCode(rest));
wprintf(L"Response body:\n");
wprintf(L"%s\n",CkStringBuilderW_getAsString(sbJson));
CkRestW_Dispose(rest);
CkOAuth2W_Dispose(oauth2);
CkStringBuilderW_Dispose(sbJson);
return;
}
json = CkJsonObjectW_Create();
CkJsonObjectW_LoadSb(json,sbJson);
// The following code parses the JSON response.
// A sample JSON response is shown below the sample code.
kind = CkJsonObjectW_stringOf(json,L"kind");
space = CkJsonObjectW_stringOf(json,L"space");
i = 0;
count_i = CkJsonObjectW_SizeOfArray(json,L"ids");
while (i < count_i) {
CkJsonObjectW_putI(json,i);
strVal = CkJsonObjectW_stringOf(json,L"ids[i]");
i = i + 1;
}
wprintf(L"Example Completed.\n");
CkRestW_Dispose(rest);
CkOAuth2W_Dispose(oauth2);
CkStringBuilderW_Dispose(sbJson);
CkJsonObjectW_Dispose(json);
}
{
"kind": "drive#generatedIds",
"space": "drive",
"ids": [
"1IT3VaUqXuF4l_4UKAFSmmC0em6kwlkle",
"1dX50zZmgzwDUonE_GI59oTF1D7RRYD3o",
"1eH17RULdRXu03inCaNuSeYkNwPS2nfUZ",
"1jXHKTHe6LazdWV0wPl8xAeHEoo_ZMBVt",
"1eBH9E3XDEczuUyfeOXT4Abq8S343qt5r",
"1R3okvS4vI1f1Psg0IJJ3dIhVQsv9SNyY",
"1rrh7NzGCgK0gYFlHC3IUdqQjcsVInN76",
"1glhBVDGFgS-61B_l0HaHBGiMRwyhuzp_",
"1gou1y4Mrq_ETHW7-GMV53e2jlhnze_2A",
"1KSUwFR7E9iDxpcLO8_hr6nnLUXGR0kAY",
"1pWt-cW7IBeEyGAkOxu8Q1KUpoHCkjGB2",
"1nnuZfxcmvq_nmHDKZLvKfohYFbs2X1q_",
"1rCGGTlP9aU9KNj_Qnt1a4ea3WdbV3NGk",
"1pLDQjyeBQvYOehHvW9mfzRzMp6yA-HOZ",
"1Ea-LO9eiwRlgJ-XvpFRxZUje1kFwaEBq",
"1nXtRHiCcIhXtY3YVcKmArlrljM2eLoGp",
"1g1VldY1fC3-w0JPycgUOU1mC524r5AHH",
"1lh1cKumE6jMc-FTfPk7y0V3jqzGydzyQ",
"1ZPdHqv3NI8tdVJ2k_XBr8cpkJYuq1E6c",
"1bxfXQmmrOUCnkZJogavDd6CF0eMSAzo9"
]
}