Back to Collection Items
#include <C_CkHttpW.h>
#include <C_CkStringBuilderW.h>
#include <C_CkJsonObjectW.h>
void ChilkatSample(void)
{
HCkHttpW http;
BOOL success;
HCkStringBuilderW sbResponseBody;
HCkJsonObjectW jResp;
int respStatusCode;
const wchar_t *id;
const wchar_t *compartmentId;
const wchar_t *shape;
const wchar_t *region;
const wchar_t *availabilityDomain;
const wchar_t *lifecycleState;
const wchar_t *timeCreated;
const wchar_t *Value;
const wchar_t *IsManagementDisabledValue;
const wchar_t *IsMonitoringDisabledValue;
const wchar_t *PluginsConfigValue;
const wchar_t *IsLiveMigrationPreferredValue;
const wchar_t *RecoveryActionValue;
const wchar_t *capacityReservationId;
const wchar_t *dedicatedVmHostId;
const wchar_t *displayName;
const wchar_t *faultDomain;
const wchar_t *imageId;
const wchar_t *AreLegacyImdsEndpointsDisabledValue;
const wchar_t *ipxeScript;
const wchar_t *launchMode;
const wchar_t *BootVolumeTypeValue;
const wchar_t *FirmwareValue;
const wchar_t *IsConsistentVolumeNamingEnabledValue;
const wchar_t *IsPvEncryptionInTransitEnabledValue;
const wchar_t *NetworkTypeValue;
const wchar_t *RemoteDataVolumeTypeValue;
const wchar_t *TypeValue;
const wchar_t *IsMeasuredBootEnabledValue;
const wchar_t *IsSecureBootEnabledValue;
const wchar_t *IsTrustedPlatformModuleEnabledValue;
const wchar_t *PreemptionActionValue;
const wchar_t *BaselineOcpuUtilizationValue;
const wchar_t *GpuDescriptionValue;
const wchar_t *GpusValue;
const wchar_t *LocalDiskDescriptionValue;
const wchar_t *LocalDisksValue;
const wchar_t *LocalDisksTotalSizeInGBsValue;
const wchar_t *MaxVnicAttachmentsValue;
const wchar_t *MemoryInGBsValue;
const wchar_t *NetworkingBandwidthInGbpsValue;
const wchar_t *OcpusValue;
const wchar_t *ProcessorDescriptionValue;
const wchar_t *SourceTypeValue;
const wchar_t *timeMaintenanceRebootDue;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http = CkHttpW_Create();
CkHttpW_SetRequestHeader(http,L"Authorization",L"{{signature}}");
CkHttpW_SetRequestHeader(http,L"Date",L"{{date}}");
sbResponseBody = CkStringBuilderW_Create();
success = CkHttpW_QuickGetSb(http,L"https://iaas.{{region}}.oraclecloud.com/20160918/instances/:instanceId",sbResponseBody);
if (success == FALSE) {
wprintf(L"%s\n",CkHttpW_lastErrorText(http));
CkHttpW_Dispose(http);
CkStringBuilderW_Dispose(sbResponseBody);
return;
}
jResp = CkJsonObjectW_Create();
CkJsonObjectW_LoadSb(jResp,sbResponseBody);
CkJsonObjectW_putEmitCompact(jResp,FALSE);
wprintf(L"Response Body:\n");
wprintf(L"%s\n",CkJsonObjectW_emit(jResp));
respStatusCode = CkHttpW_getLastStatus(http);
wprintf(L"Response Status Code = %d\n",respStatusCode);
if (respStatusCode >= 400) {
wprintf(L"Response Header:\n");
wprintf(L"%s\n",CkHttpW_lastHeader(http));
wprintf(L"Failed.\n");
CkHttpW_Dispose(http);
CkStringBuilderW_Dispose(sbResponseBody);
CkJsonObjectW_Dispose(jResp);
return;
}
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "id": "sit dolor",
// "compartmentId": "et esse",
// "shape": "sunt veniam",
// "region": "laboris",
// "availabilityDomain": "dolor",
// "lifecycleState": "TERMINATED",
// "timeCreated": "2006-02-03T20:50:31.716Z",
// "agentConfig": {
// "areAllPluginsDisabled": {
// "value": "<Error: Too many levels of nesting to fake this schema>"
// },
// "isManagementDisabled": {
// "value": "<Error: Too many levels of nesting to fake this schema>"
// },
// "isMonitoringDisabled": {
// "value": "<Error: Too many levels of nesting to fake this schema>"
// },
// "pluginsConfig": {
// "value": "<Error: Too many levels of nesting to fake this schema>"
// }
// },
// "availabilityConfig": {
// "isLiveMigrationPreferred": {
// "value": "<Error: Too many levels of nesting to fake this schema>"
// },
// "recoveryAction": {
// "value": "<Error: Too many levels of nesting to fake this schema>"
// }
// },
// "capacityReservationId": "occaecat sint id",
// "dedicatedVmHostId": "ipsum dolor incididunt sit ex",
// "definedTags": {},
// "displayName": "consequat aliquip magna ullamco",
// "extendedMetadata": {},
// "faultDomain": "incididunt esse",
// "freeformTags": {},
// "imageId": "dolor nulla consequat ipsum",
// "instanceOptions": {
// "areLegacyImdsEndpointsDisabled": {
// "value": "<Error: Too many levels of nesting to fake this schema>"
// }
// },
// "ipxeScript": "anim magna",
// "launchMode": "CUSTOM",
// "launchOptions": {
// "bootVolumeType": {
// "value": "<Error: Too many levels of nesting to fake this schema>"
// },
// "firmware": {
// "value": "<Error: Too many levels of nesting to fake this schema>"
// },
// "isConsistentVolumeNamingEnabled": {
// "value": "<Error: Too many levels of nesting to fake this schema>"
// },
// "isPvEncryptionInTransitEnabled": {
// "value": "<Error: Too many levels of nesting to fake this schema>"
// },
// "networkType": {
// "value": "<Error: Too many levels of nesting to fake this schema>"
// },
// "remoteDataVolumeType": {
// "value": "<Error: Too many levels of nesting to fake this schema>"
// }
// },
// "metadata": {},
// "platformConfig": {
// "type": {
// "value": "<Error: Too many levels of nesting to fake this schema>"
// },
// "isMeasuredBootEnabled": {
// "value": "<Error: Too many levels of nesting to fake this schema>"
// },
// "isSecureBootEnabled": {
// "value": "<Error: Too many levels of nesting to fake this schema>"
// },
// "isTrustedPlatformModuleEnabled": {
// "value": "<Error: Too many levels of nesting to fake this schema>"
// }
// },
// "preemptibleInstanceConfig": {
// "preemptionAction": {
// "value": "<Error: Too many levels of nesting to fake this schema>"
// }
// },
// "shapeConfig": {
// "baselineOcpuUtilization": {
// "value": "<Error: Too many levels of nesting to fake this schema>"
// },
// "gpuDescription": {
// "value": "<Error: Too many levels of nesting to fake this schema>"
// },
// "gpus": {
// "value": "<Error: Too many levels of nesting to fake this schema>"
// },
// "localDiskDescription": {
// "value": "<Error: Too many levels of nesting to fake this schema>"
// },
// "localDisks": {
// "value": "<Error: Too many levels of nesting to fake this schema>"
// },
// "localDisksTotalSizeInGBs": {
// "value": "<Error: Too many levels of nesting to fake this schema>"
// },
// "maxVnicAttachments": {
// "value": "<Error: Too many levels of nesting to fake this schema>"
// },
// "memoryInGBs": {
// "value": "<Error: Too many levels of nesting to fake this schema>"
// },
// "networkingBandwidthInGbps": {
// "value": "<Error: Too many levels of nesting to fake this schema>"
// },
// "ocpus": {
// "value": "<Error: Too many levels of nesting to fake this schema>"
// },
// "processorDescription": {
// "value": "<Error: Too many levels of nesting to fake this schema>"
// }
// },
// "sourceDetails": {
// "sourceType": {
// "value": "<Error: Too many levels of nesting to fake this schema>"
// }
// },
// "timeMaintenanceRebootDue": "1973-07-06T14:36:00.263Z"
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
// Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat.
id = CkJsonObjectW_stringOf(jResp,L"id");
compartmentId = CkJsonObjectW_stringOf(jResp,L"compartmentId");
shape = CkJsonObjectW_stringOf(jResp,L"shape");
region = CkJsonObjectW_stringOf(jResp,L"region");
availabilityDomain = CkJsonObjectW_stringOf(jResp,L"availabilityDomain");
lifecycleState = CkJsonObjectW_stringOf(jResp,L"lifecycleState");
timeCreated = CkJsonObjectW_stringOf(jResp,L"timeCreated");
Value = CkJsonObjectW_stringOf(jResp,L"agentConfig.areAllPluginsDisabled.value");
IsManagementDisabledValue = CkJsonObjectW_stringOf(jResp,L"agentConfig.isManagementDisabled.value");
IsMonitoringDisabledValue = CkJsonObjectW_stringOf(jResp,L"agentConfig.isMonitoringDisabled.value");
PluginsConfigValue = CkJsonObjectW_stringOf(jResp,L"agentConfig.pluginsConfig.value");
IsLiveMigrationPreferredValue = CkJsonObjectW_stringOf(jResp,L"availabilityConfig.isLiveMigrationPreferred.value");
RecoveryActionValue = CkJsonObjectW_stringOf(jResp,L"availabilityConfig.recoveryAction.value");
capacityReservationId = CkJsonObjectW_stringOf(jResp,L"capacityReservationId");
dedicatedVmHostId = CkJsonObjectW_stringOf(jResp,L"dedicatedVmHostId");
displayName = CkJsonObjectW_stringOf(jResp,L"displayName");
faultDomain = CkJsonObjectW_stringOf(jResp,L"faultDomain");
imageId = CkJsonObjectW_stringOf(jResp,L"imageId");
AreLegacyImdsEndpointsDisabledValue = CkJsonObjectW_stringOf(jResp,L"instanceOptions.areLegacyImdsEndpointsDisabled.value");
ipxeScript = CkJsonObjectW_stringOf(jResp,L"ipxeScript");
launchMode = CkJsonObjectW_stringOf(jResp,L"launchMode");
BootVolumeTypeValue = CkJsonObjectW_stringOf(jResp,L"launchOptions.bootVolumeType.value");
FirmwareValue = CkJsonObjectW_stringOf(jResp,L"launchOptions.firmware.value");
IsConsistentVolumeNamingEnabledValue = CkJsonObjectW_stringOf(jResp,L"launchOptions.isConsistentVolumeNamingEnabled.value");
IsPvEncryptionInTransitEnabledValue = CkJsonObjectW_stringOf(jResp,L"launchOptions.isPvEncryptionInTransitEnabled.value");
NetworkTypeValue = CkJsonObjectW_stringOf(jResp,L"launchOptions.networkType.value");
RemoteDataVolumeTypeValue = CkJsonObjectW_stringOf(jResp,L"launchOptions.remoteDataVolumeType.value");
TypeValue = CkJsonObjectW_stringOf(jResp,L"platformConfig.type.value");
IsMeasuredBootEnabledValue = CkJsonObjectW_stringOf(jResp,L"platformConfig.isMeasuredBootEnabled.value");
IsSecureBootEnabledValue = CkJsonObjectW_stringOf(jResp,L"platformConfig.isSecureBootEnabled.value");
IsTrustedPlatformModuleEnabledValue = CkJsonObjectW_stringOf(jResp,L"platformConfig.isTrustedPlatformModuleEnabled.value");
PreemptionActionValue = CkJsonObjectW_stringOf(jResp,L"preemptibleInstanceConfig.preemptionAction.value");
BaselineOcpuUtilizationValue = CkJsonObjectW_stringOf(jResp,L"shapeConfig.baselineOcpuUtilization.value");
GpuDescriptionValue = CkJsonObjectW_stringOf(jResp,L"shapeConfig.gpuDescription.value");
GpusValue = CkJsonObjectW_stringOf(jResp,L"shapeConfig.gpus.value");
LocalDiskDescriptionValue = CkJsonObjectW_stringOf(jResp,L"shapeConfig.localDiskDescription.value");
LocalDisksValue = CkJsonObjectW_stringOf(jResp,L"shapeConfig.localDisks.value");
LocalDisksTotalSizeInGBsValue = CkJsonObjectW_stringOf(jResp,L"shapeConfig.localDisksTotalSizeInGBs.value");
MaxVnicAttachmentsValue = CkJsonObjectW_stringOf(jResp,L"shapeConfig.maxVnicAttachments.value");
MemoryInGBsValue = CkJsonObjectW_stringOf(jResp,L"shapeConfig.memoryInGBs.value");
NetworkingBandwidthInGbpsValue = CkJsonObjectW_stringOf(jResp,L"shapeConfig.networkingBandwidthInGbps.value");
OcpusValue = CkJsonObjectW_stringOf(jResp,L"shapeConfig.ocpus.value");
ProcessorDescriptionValue = CkJsonObjectW_stringOf(jResp,L"shapeConfig.processorDescription.value");
SourceTypeValue = CkJsonObjectW_stringOf(jResp,L"sourceDetails.sourceType.value");
timeMaintenanceRebootDue = CkJsonObjectW_stringOf(jResp,L"timeMaintenanceRebootDue");
CkHttpW_Dispose(http);
CkStringBuilderW_Dispose(sbResponseBody);
CkJsonObjectW_Dispose(jResp);
}
Curl Command
curl -X GET
-H "Date: {{date}}"
-H "Authorization: {{signature}}"
https://iaas.{{region}}.oraclecloud.com/20160918/instances/:instanceId
Postman Collection Item JSON
{
"name": "GetInstance",
"request": {
"method": "GET",
"header": [
{
"key": "Date",
"value": "{{date}}",
"description": "(Required) Current Date",
"type": "text"
},
{
"key": "Authorization",
"value": "{{signature}}",
"description": "(Required) Signature Authentication on Authorization header",
"type": "text"
}
],
"url": {
"raw": "{{baseUrl}}/instances/:instanceId",
"host": [
"{{baseUrl}}"
],
"path": [
"instances",
":instanceId"
],
"variable": [
{
"key": "instanceId",
"value": "officia sed",
"description": "(Required) The [OCID](/iaas/Content/General/Concepts/identifiers.htm) of the instance."
}
]
},
"description": "Gets information about the specified instance."
},
"response": [
{
"name": "The instance was retrieved.",
"originalRequest": {
"method": "GET",
"header": [
],
"url": {
"raw": "{{baseUrl}}/instances/:instanceId",
"host": [
"{{baseUrl}}"
],
"path": [
"instances",
":instanceId"
],
"variable": [
{
"key": "instanceId"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "etag",
"value": "officia sed",
"description": "For optimistic concurrency control. See `if-match`.\n"
},
{
"key": "opc-request-id",
"value": "officia sed",
"description": "Unique Oracle-assigned identifier for the request. If you need to contact\nOracle about a particular request, please provide the request ID.\n"
},
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"id\": \"sit dolor\",\n \"compartmentId\": \"et esse\",\n \"shape\": \"sunt veniam\",\n \"region\": \"laboris\",\n \"availabilityDomain\": \"dolor\",\n \"lifecycleState\": \"TERMINATED\",\n \"timeCreated\": \"2006-02-03T20:50:31.716Z\",\n \"agentConfig\": {\n \"areAllPluginsDisabled\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n \"isManagementDisabled\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n \"isMonitoringDisabled\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n \"pluginsConfig\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n }\n },\n \"availabilityConfig\": {\n \"isLiveMigrationPreferred\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n \"recoveryAction\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n }\n },\n \"capacityReservationId\": \"occaecat sint id\",\n \"dedicatedVmHostId\": \"ipsum dolor incididunt sit ex\",\n \"definedTags\": {},\n \"displayName\": \"consequat aliquip magna ullamco\",\n \"extendedMetadata\": {},\n \"faultDomain\": \"incididunt esse\",\n \"freeformTags\": {},\n \"imageId\": \"dolor nulla consequat ipsum\",\n \"instanceOptions\": {\n \"areLegacyImdsEndpointsDisabled\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n }\n },\n \"ipxeScript\": \"anim magna\",\n \"launchMode\": \"CUSTOM\",\n \"launchOptions\": {\n \"bootVolumeType\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n \"firmware\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n \"isConsistentVolumeNamingEnabled\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n \"isPvEncryptionInTransitEnabled\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n \"networkType\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n \"remoteDataVolumeType\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n }\n },\n \"metadata\": {},\n \"platformConfig\": {\n \"type\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n \"isMeasuredBootEnabled\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n \"isSecureBootEnabled\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n \"isTrustedPlatformModuleEnabled\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n }\n },\n \"preemptibleInstanceConfig\": {\n \"preemptionAction\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n }\n },\n \"shapeConfig\": {\n \"baselineOcpuUtilization\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n \"gpuDescription\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n \"gpus\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n \"localDiskDescription\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n \"localDisks\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n \"localDisksTotalSizeInGBs\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n \"maxVnicAttachments\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n \"memoryInGBs\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n \"networkingBandwidthInGbps\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n \"ocpus\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n \"processorDescription\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n }\n },\n \"sourceDetails\": {\n \"sourceType\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n }\n },\n \"timeMaintenanceRebootDue\": \"1973-07-06T14:36:00.263Z\"\n}"
},
{
"name": "Unauthorized",
"originalRequest": {
"method": "GET",
"header": [
],
"url": {
"raw": "{{baseUrl}}/instances/:instanceId",
"host": [
"{{baseUrl}}"
],
"path": [
"instances",
":instanceId"
],
"variable": [
{
"key": "instanceId"
}
]
}
},
"status": "Unauthorized",
"code": 401,
"_postman_previewlanguage": "json",
"header": [
{
"key": "opc-request-id",
"value": "officia sed",
"description": "Unique Oracle-assigned identifier for the request. If you need to contact\nOracle about a particular request, please provide the request ID.\n"
},
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"code\": \"et exercitation Excepteur\",\n \"message\": \"irure sit\"\n}"
},
{
"name": "Not Found",
"originalRequest": {
"method": "GET",
"header": [
],
"url": {
"raw": "{{baseUrl}}/instances/:instanceId",
"host": [
"{{baseUrl}}"
],
"path": [
"instances",
":instanceId"
],
"variable": [
{
"key": "instanceId"
}
]
}
},
"status": "Not Found",
"code": 404,
"_postman_previewlanguage": "json",
"header": [
{
"key": "opc-request-id",
"value": "officia sed",
"description": "Unique Oracle-assigned identifier for the request. If you need to contact\nOracle about a particular request, please provide the request ID.\n"
},
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"code\": \"et exercitation Excepteur\",\n \"message\": \"irure sit\"\n}"
},
{
"name": "Internal Server Error",
"originalRequest": {
"method": "GET",
"header": [
],
"url": {
"raw": "{{baseUrl}}/instances/:instanceId",
"host": [
"{{baseUrl}}"
],
"path": [
"instances",
":instanceId"
],
"variable": [
{
"key": "instanceId"
}
]
}
},
"status": "Internal Server Error",
"code": 500,
"_postman_previewlanguage": "json",
"header": [
{
"key": "opc-request-id",
"value": "officia sed",
"description": "Unique Oracle-assigned identifier for the request. If you need to contact\nOracle about a particular request, please provide the request ID.\n"
},
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"code\": \"et exercitation Excepteur\",\n \"message\": \"irure sit\"\n}"
},
{
"name": "An error has occurred.",
"originalRequest": {
"method": "GET",
"header": [
],
"url": {
"raw": "{{baseUrl}}/instances/:instanceId",
"host": [
"{{baseUrl}}"
],
"path": [
"instances",
":instanceId"
],
"variable": [
{
"key": "instanceId"
}
]
}
},
"status": "Internal Server Error",
"code": 500,
"_postman_previewlanguage": "json",
"header": [
{
"key": "opc-request-id",
"value": "officia sed",
"description": "Unique Oracle-assigned identifier for the request. If you need to contact\nOracle about a particular request, please provide the request ID.\n"
},
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"code\": \"et exercitation Excepteur\",\n \"message\": \"irure sit\"\n}"
}
]
}