Back to Collection Items
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Chilkat.Http http = new Chilkat.Http();
bool success;
// Use this online tool to generate code from sample JSON: Generate Code to Create JSON
// The following JSON is sent in the request body.
// {
// "compartmentId": "{{compartment_ocid}}",
// "cidrBlock": "laboris qui id proident",
// "cidrBlocks": [
// "dolore deserunt",
// "nulla elit proident"
// ],
// "definedTags": {},
// "displayName": "reprehenderit pariatur ipsum quis",
// "dnsLabel": "magn",
// "freeformTags": {},
// "ipv6CidrBlock": "velit aliquip dolore",
// "isIpv6Enabled": true
// }
Chilkat.JsonObject json = new Chilkat.JsonObject();
json.UpdateString("compartmentId","{{compartment_ocid}}");
json.UpdateString("cidrBlock","laboris qui id proident");
json.UpdateString("cidrBlocks[0]","dolore deserunt");
json.UpdateString("cidrBlocks[1]","nulla elit proident");
json.UpdateNewObject("definedTags");
json.UpdateString("displayName","reprehenderit pariatur ipsum quis");
json.UpdateString("dnsLabel","magn");
json.UpdateNewObject("freeformTags");
json.UpdateString("ipv6CidrBlock","velit aliquip dolore");
json.UpdateBool("isIpv6Enabled",true);
http.SetRequestHeader("opc-retry-token","aliqua enim i");
http.SetRequestHeader("Content-Type","application/json");
http.SetRequestHeader("x-content-sha256","{{content_sha256}}");
http.SetRequestHeader("Authorization","{{signature}}");
http.SetRequestHeader("Date","{{date}}");
Chilkat.HttpResponse resp = http.PostJson3("https://iaas.{{region}}.oraclecloud.com/20160918/vcns","application/json",json);
if (http.LastMethodSuccess == false) {
Debug.WriteLine(http.LastErrorText);
return;
}
Chilkat.StringBuilder sbResponseBody = new Chilkat.StringBuilder();
resp.GetBodySb(sbResponseBody);
Chilkat.JsonObject jResp = new Chilkat.JsonObject();
jResp.LoadSb(sbResponseBody);
jResp.EmitCompact = false;
Debug.WriteLine("Response Body:");
Debug.WriteLine(jResp.Emit());
int respStatusCode = resp.StatusCode;
Debug.WriteLine("Response Status Code = " + Convert.ToString(respStatusCode));
if (respStatusCode >= 400) {
Debug.WriteLine("Response Header:");
Debug.WriteLine(resp.Header);
Debug.WriteLine("Failed.");
return;
}
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "id": "id magna consectetur",
// "compartmentId": "proident ullamco et non",
// "cidrBlock": "ut amet la",
// "lifecycleState": "TERMINATING",
// "cidrBlocks": [
// "et",
// "amet"
// ],
// "defaultDhcpOptionsId": "qui officia reprehenderit Ut",
// "defaultRouteTableId": "nulla incididunt exercitation fugiat",
// "defaultSecurityListId": "eiusmod sint aliqua",
// "definedTags": {},
// "displayName": "in",
// "dnsLabel": "qui cupida",
// "freeformTags": {},
// "ipv6CidrBlock": "aute Excepteur",
// "ipv6PublicCidrBlock": "dolore ex dolor Lorem adipisicing",
// "timeCreated": "1985-03-26T20:05:22.459Z",
// "vcnDomainName": "ex laborum magna"
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
string strVal;
string id = jResp.StringOf("id");
string compartmentId = jResp.StringOf("compartmentId");
string cidrBlock = jResp.StringOf("cidrBlock");
string lifecycleState = jResp.StringOf("lifecycleState");
string defaultDhcpOptionsId = jResp.StringOf("defaultDhcpOptionsId");
string defaultRouteTableId = jResp.StringOf("defaultRouteTableId");
string defaultSecurityListId = jResp.StringOf("defaultSecurityListId");
string displayName = jResp.StringOf("displayName");
string dnsLabel = jResp.StringOf("dnsLabel");
string ipv6CidrBlock = jResp.StringOf("ipv6CidrBlock");
string ipv6PublicCidrBlock = jResp.StringOf("ipv6PublicCidrBlock");
string timeCreated = jResp.StringOf("timeCreated");
string vcnDomainName = jResp.StringOf("vcnDomainName");
int i = 0;
int count_i = jResp.SizeOfArray("cidrBlocks");
while (i < count_i) {
jResp.I = i;
strVal = jResp.StringOf("cidrBlocks[i]");
i = i + 1;
}
Curl Command
curl -X POST
-H "opc-retry-token: aliqua enim i"
-H "Content-Type: application/json"
-H "Date: {{date}}"
-H "Authorization: {{signature}}"
-H "x-content-sha256: {{content_sha256}}"
-d '{
"compartmentId": "{{compartment_ocid}}",
"cidrBlock": "laboris qui id proident",
"cidrBlocks": [
"dolore deserunt",
"nulla elit proident"
],
"definedTags": {},
"displayName": "reprehenderit pariatur ipsum quis",
"dnsLabel": "magn",
"freeformTags": {},
"ipv6CidrBlock": "velit aliquip dolore",
"isIpv6Enabled": true
}'
https://iaas.{{region}}.oraclecloud.com/20160918/vcns
Postman Collection Item JSON
{
"name": "CreateVcn",
"request": {
"method": "POST",
"header": [
{
"description": "A token that uniquely identifies a request so it can be retried in case of a timeout or\nserver error without risk of executing that same action again. Retry tokens expire after 24\nhours, but can be invalidated before then due to conflicting operations (for example, if a resource\nhas been deleted and purged from the system, then a retry of the original creation request\nmay be rejected).\n",
"key": "opc-retry-token",
"value": "aliqua enim i"
},
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Date",
"value": "{{date}}",
"description": "(Required) Current Date",
"type": "text"
},
{
"key": "Authorization",
"value": "{{signature}}",
"description": "(Required) Signature Authentication on Authorization header",
"type": "text"
},
{
"key": "x-content-sha256",
"value": "{{content_sha256}}",
"description": "(Required) Content sha256 for POST, PUT and PATCH operations",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"compartmentId\": \"{{compartment_ocid}}\",\n \"cidrBlock\": \"laboris qui id proident\",\n \"cidrBlocks\": [\n \"dolore deserunt\",\n \"nulla elit proident\"\n ],\n \"definedTags\": {},\n \"displayName\": \"reprehenderit pariatur ipsum quis\",\n \"dnsLabel\": \"magn\",\n \"freeformTags\": {},\n \"ipv6CidrBlock\": \"velit aliquip dolore\",\n \"isIpv6Enabled\": true\n}"
},
"url": {
"raw": "{{baseUrl}}/vcns",
"host": [
"{{baseUrl}}"
],
"path": [
"vcns"
]
},
"description": "Creates a new virtual cloud network (VCN). For more information, see\n[VCNs and Subnets](/iaas/Content/Network/Tasks/managingVCNs.htm).\n\nFor the VCN, you specify a list of one or more IPv4 CIDR blocks that meet the following criteria:\n\n- The CIDR blocks must be valid.\n- They must not overlap with each other or with the on-premises network CIDR block. \n- The number of CIDR blocks does not exceed the limit of CIDR blocks allowed per VCN.\n\nFor a CIDR block, Oracle recommends that you use one of the private IP address ranges specified in [RFC 1918](https://tools.ietf.org/html/rfc1918) (10.0.0.0/8, 172.16/12, and 192.168/16). Example:\n172.16.0.0/16. The CIDR blocks can range from /16 to /30.\n\nFor the purposes of access control, you must provide the [OCID](/iaas/Content/General/Concepts/identifiers.htm) of the compartment where you want the VCN to\nreside. Consult an Oracle Cloud Infrastructure administrator in your organization if you're not sure which\ncompartment to use. Notice that the VCN doesn't have to be in the same compartment as the subnets or other\nNetworking Service components. For more information about compartments and access control, see\n[Overview of the IAM Service](/iaas/Content/Identity/Concepts/overview.htm). For information about OCIDs, see\n[Resource Identifiers](/iaas/Content/General/Concepts/identifiers.htm).\n\nYou may optionally specify a *display name* for the VCN, otherwise a default is provided. It does not have to\nbe unique, and you can change it. Avoid entering confidential information.\n\nYou can also add a DNS label for the VCN, which is required if you want the instances to use the\nInterent and VCN Resolver option for DNS in the VCN. For more information, see\n[DNS in Your Virtual Cloud Network](/iaas/Content/Network/Concepts/dns.htm).\n\nThe VCN automatically comes with a default route table, default security list, and default set of DHCP options.\nThe [OCID](/iaas/Content/General/Concepts/identifiers.htm) for each is returned in the response. You can't delete these default objects, but you can change their\ncontents (that is, change the route rules, security list rules, and so on).\n\nThe VCN and subnets you create are not accessible until you attach an internet gateway or set up a Site-to-Site VPN\nor FastConnect. For more information, see\n[Overview of the Networking Service](/iaas/Content/Network/Concepts/overview.htm).\n"
},
"response": [
{
"name": "The VCN was created.",
"originalRequest": {
"method": "POST",
"header": [
{
"description": "A token that uniquely identifies a request so it can be retried in case of a timeout or\nserver error without risk of executing that same action again. Retry tokens expire after 24\nhours, but can be invalidated before then due to conflicting operations (for example, if a resource\nhas been deleted and purged from the system, then a retry of the original creation request\nmay be rejected).\n",
"key": "opc-retry-token",
"value": "aliqua enim i"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"compartmentId\": \"pariatur\",\n \"cidrBlock\": \"laboris qui id proident\",\n \"cidrBlocks\": [\n \"dolore deserunt\",\n \"nulla elit proident\"\n ],\n \"definedTags\": {},\n \"displayName\": \"reprehenderit pariatur ipsum quis\",\n \"dnsLabel\": \"magn\",\n \"freeformTags\": {},\n \"ipv6CidrBlock\": \"velit aliquip dolore\",\n \"isIpv6Enabled\": true\n}"
},
"url": {
"raw": "{{baseUrl}}/vcns",
"host": [
"{{baseUrl}}"
],
"path": [
"vcns"
]
}
},
"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\": \"id magna consectetur\",\n \"compartmentId\": \"proident ullamco et non\",\n \"cidrBlock\": \"ut amet la\",\n \"lifecycleState\": \"TERMINATING\",\n \"cidrBlocks\": [\n \"et\",\n \"amet\"\n ],\n \"defaultDhcpOptionsId\": \"qui officia reprehenderit Ut\",\n \"defaultRouteTableId\": \"nulla incididunt exercitation fugiat\",\n \"defaultSecurityListId\": \"eiusmod sint aliqua\",\n \"definedTags\": {},\n \"displayName\": \"in\",\n \"dnsLabel\": \"qui cupida\",\n \"freeformTags\": {},\n \"ipv6CidrBlock\": \"aute Excepteur\",\n \"ipv6PublicCidrBlock\": \"dolore ex dolor Lorem adipisicing\",\n \"timeCreated\": \"1985-03-26T20:05:22.459Z\",\n \"vcnDomainName\": \"ex laborum magna\"\n}"
},
{
"name": "Bad Request",
"originalRequest": {
"method": "POST",
"header": [
{
"description": "A token that uniquely identifies a request so it can be retried in case of a timeout or\nserver error without risk of executing that same action again. Retry tokens expire after 24\nhours, but can be invalidated before then due to conflicting operations (for example, if a resource\nhas been deleted and purged from the system, then a retry of the original creation request\nmay be rejected).\n",
"key": "opc-retry-token",
"value": "aliqua enim i"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"compartmentId\": \"pariatur\",\n \"cidrBlock\": \"laboris qui id proident\",\n \"cidrBlocks\": [\n \"dolore deserunt\",\n \"nulla elit proident\"\n ],\n \"definedTags\": {},\n \"displayName\": \"reprehenderit pariatur ipsum quis\",\n \"dnsLabel\": \"magn\",\n \"freeformTags\": {},\n \"ipv6CidrBlock\": \"velit aliquip dolore\",\n \"isIpv6Enabled\": true\n}"
},
"url": {
"raw": "{{baseUrl}}/vcns",
"host": [
"{{baseUrl}}"
],
"path": [
"vcns"
]
}
},
"status": "Bad Request",
"code": 400,
"_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": "Unauthorized",
"originalRequest": {
"method": "POST",
"header": [
{
"description": "A token that uniquely identifies a request so it can be retried in case of a timeout or\nserver error without risk of executing that same action again. Retry tokens expire after 24\nhours, but can be invalidated before then due to conflicting operations (for example, if a resource\nhas been deleted and purged from the system, then a retry of the original creation request\nmay be rejected).\n",
"key": "opc-retry-token",
"value": "aliqua enim i"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"compartmentId\": \"pariatur\",\n \"cidrBlock\": \"laboris qui id proident\",\n \"cidrBlocks\": [\n \"dolore deserunt\",\n \"nulla elit proident\"\n ],\n \"definedTags\": {},\n \"displayName\": \"reprehenderit pariatur ipsum quis\",\n \"dnsLabel\": \"magn\",\n \"freeformTags\": {},\n \"ipv6CidrBlock\": \"velit aliquip dolore\",\n \"isIpv6Enabled\": true\n}"
},
"url": {
"raw": "{{baseUrl}}/vcns",
"host": [
"{{baseUrl}}"
],
"path": [
"vcns"
]
}
},
"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": "POST",
"header": [
{
"description": "A token that uniquely identifies a request so it can be retried in case of a timeout or\nserver error without risk of executing that same action again. Retry tokens expire after 24\nhours, but can be invalidated before then due to conflicting operations (for example, if a resource\nhas been deleted and purged from the system, then a retry of the original creation request\nmay be rejected).\n",
"key": "opc-retry-token",
"value": "aliqua enim i"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"compartmentId\": \"pariatur\",\n \"cidrBlock\": \"laboris qui id proident\",\n \"cidrBlocks\": [\n \"dolore deserunt\",\n \"nulla elit proident\"\n ],\n \"definedTags\": {},\n \"displayName\": \"reprehenderit pariatur ipsum quis\",\n \"dnsLabel\": \"magn\",\n \"freeformTags\": {},\n \"ipv6CidrBlock\": \"velit aliquip dolore\",\n \"isIpv6Enabled\": true\n}"
},
"url": {
"raw": "{{baseUrl}}/vcns",
"host": [
"{{baseUrl}}"
],
"path": [
"vcns"
]
}
},
"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": "Conflict",
"originalRequest": {
"method": "POST",
"header": [
{
"description": "A token that uniquely identifies a request so it can be retried in case of a timeout or\nserver error without risk of executing that same action again. Retry tokens expire after 24\nhours, but can be invalidated before then due to conflicting operations (for example, if a resource\nhas been deleted and purged from the system, then a retry of the original creation request\nmay be rejected).\n",
"key": "opc-retry-token",
"value": "aliqua enim i"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"compartmentId\": \"pariatur\",\n \"cidrBlock\": \"laboris qui id proident\",\n \"cidrBlocks\": [\n \"dolore deserunt\",\n \"nulla elit proident\"\n ],\n \"definedTags\": {},\n \"displayName\": \"reprehenderit pariatur ipsum quis\",\n \"dnsLabel\": \"magn\",\n \"freeformTags\": {},\n \"ipv6CidrBlock\": \"velit aliquip dolore\",\n \"isIpv6Enabled\": true\n}"
},
"url": {
"raw": "{{baseUrl}}/vcns",
"host": [
"{{baseUrl}}"
],
"path": [
"vcns"
]
}
},
"status": "Conflict",
"code": 409,
"_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": "POST",
"header": [
{
"description": "A token that uniquely identifies a request so it can be retried in case of a timeout or\nserver error without risk of executing that same action again. Retry tokens expire after 24\nhours, but can be invalidated before then due to conflicting operations (for example, if a resource\nhas been deleted and purged from the system, then a retry of the original creation request\nmay be rejected).\n",
"key": "opc-retry-token",
"value": "aliqua enim i"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"compartmentId\": \"pariatur\",\n \"cidrBlock\": \"laboris qui id proident\",\n \"cidrBlocks\": [\n \"dolore deserunt\",\n \"nulla elit proident\"\n ],\n \"definedTags\": {},\n \"displayName\": \"reprehenderit pariatur ipsum quis\",\n \"dnsLabel\": \"magn\",\n \"freeformTags\": {},\n \"ipv6CidrBlock\": \"velit aliquip dolore\",\n \"isIpv6Enabled\": true\n}"
},
"url": {
"raw": "{{baseUrl}}/vcns",
"host": [
"{{baseUrl}}"
],
"path": [
"vcns"
]
}
},
"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": "POST",
"header": [
{
"description": "A token that uniquely identifies a request so it can be retried in case of a timeout or\nserver error without risk of executing that same action again. Retry tokens expire after 24\nhours, but can be invalidated before then due to conflicting operations (for example, if a resource\nhas been deleted and purged from the system, then a retry of the original creation request\nmay be rejected).\n",
"key": "opc-retry-token",
"value": "aliqua enim i"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"compartmentId\": \"pariatur\",\n \"cidrBlock\": \"laboris qui id proident\",\n \"cidrBlocks\": [\n \"dolore deserunt\",\n \"nulla elit proident\"\n ],\n \"definedTags\": {},\n \"displayName\": \"reprehenderit pariatur ipsum quis\",\n \"dnsLabel\": \"magn\",\n \"freeformTags\": {},\n \"ipv6CidrBlock\": \"velit aliquip dolore\",\n \"isIpv6Enabled\": true\n}"
},
"url": {
"raw": "{{baseUrl}}/vcns",
"host": [
"{{baseUrl}}"
],
"path": [
"vcns"
]
}
},
"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}"
}
]
}