Chilkat Online Tools

Swift / Salesforce Platform APIs / Refresh Sandbox

Back to Collection Items

func chilkatTest() {
    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    let http = CkoHttp()
    var success: Bool

    // Use this online tool to generate code from sample JSON: Generate Code to Create JSON

    // The following JSON is sent in the request body.

    // {
    //   "LicenseType": "DEVELOPER",
    //   "AutoActivate": true
    // }

    let json = CkoJsonObject()
    json.UpdateString("LicenseType", value: "DEVELOPER")
    json.UpdateBool("AutoActivate", value: true)

    // Adds the "Authorization: Bearer <access_token>" header.
    http.AuthToken = "<access_token>"
    http.SetRequestHeader("Content-Type", value: "application/json")

    let sbRequestBody = CkoStringBuilder()
    json.EmitSb(sbRequestBody)

    var resp: CkoHttpResponse? = http.PTextSb("PATCH", url: "https://domain.com/services/data/v{{version}}/tooling/sobjects/SandboxInfo/:SANDBOX_INFO_ID", textData: sbRequestBody, charset: "utf-8", contentType: "application/json", md5: false, gzip: false)
    if http.LastMethodSuccess == false {
        print("\(http.LastErrorText)")
        return
    }

    print("\(resp!.StatusCode.intValue)")
    print("\(resp!.BodyStr)")
    resp = nil

}

Curl Command

curl -X PATCH
	-H "Authorization: Bearer <access_token>"
	-H "Content-Type: application/json"
	-d '{
    "LicenseType": "DEVELOPER",
    "AutoActivate": true
}'
https://domain.com/services/data/v{{version}}/tooling/sobjects/SandboxInfo/:SANDBOX_INFO_ID

Postman Collection Item JSON

{
  "name": "Refresh Sandbox",
  "request": {
    "method": "PATCH",
    "header": [
      {
        "key": "Content-Type",
        "value": "application/json",
        "type": "text"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n    \"LicenseType\": \"DEVELOPER\",\n    \"AutoActivate\": true\n}",
      "options": {
        "raw": {
          "language": "json"
        }
      }
    },
    "url": {
      "raw": "{{_endpoint}}/services/data/v{{version}}/tooling/sobjects/SandboxInfo/:SANDBOX_INFO_ID",
      "host": [
        "{{_endpoint}}"
      ],
      "path": [
        "services",
        "data",
        "v{{version}}",
        "tooling",
        "sobjects",
        "SandboxInfo",
        ":SANDBOX_INFO_ID"
      ],
      "variable": [
        {
          "key": "SANDBOX_INFO_ID",
          "value": ""
        }
      ]
    },
    "description": "Refreshes a sandbox."
  },
  "response": [
    {
      "name": "Refresh Sandbox",
      "originalRequest": {
        "method": "PATCH",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n    \"LicenseType\": \"DEVELOPER\",\n    \"AutoActivate\": true\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{_endpoint}}/services/data/v{{version}}/tooling/sobjects/SandboxInfo/:SANDBOX_INFO_ID",
          "host": [
            "{{_endpoint}}"
          ],
          "path": [
            "services",
            "data",
            "v{{version}}",
            "tooling",
            "sobjects",
            "SandboxInfo",
            ":SANDBOX_INFO_ID"
          ],
          "variable": [
            {
              "key": "SANDBOX_INFO_ID",
              "value": "0GQ4H000000CxSzWAK"
            }
          ]
        }
      },
      "status": "No Content",
      "code": 204,
      "_postman_previewlanguage": "plain",
      "header": [
        {
          "key": "Date",
          "value": "Wed, 13 Dec 2023 12:33:55 GMT"
        },
        {
          "key": "Strict-Transport-Security",
          "value": "max-age=63072000; includeSubDomains"
        },
        {
          "key": "X-Content-Type-Options",
          "value": "nosniff"
        },
        {
          "key": "Content-Security-Policy",
          "value": "upgrade-insecure-requests"
        },
        {
          "key": "X-Robots-Tag",
          "value": "none"
        },
        {
          "key": "Cache-Control",
          "value": "no-cache,must-revalidate,max-age=0,no-store,private"
        },
        {
          "key": "Sforce-Limit-Info",
          "value": "api-usage=2/15000"
        }
      ],
      "cookie": [
      ],
      "body": null
    }
  ]
}