2

In a series of questions regarding the Tooling API... one more rofl

I'm trying to refresh a Sandbox via the Tooling API. For that, according to the documentation:

To refresh a sandbox:

  1. To start a sandbox refresh, edit the SandboxInfo record.
  2. To find the status of a sandbox after it is enqueued, find the latest SandboxProcess record by querying SandboxProcess for a given SandboxInfoId value. The value of Status indicates the current state of the process.
  3. When the Status field value is Pending Activation, change the value of the RefreshAction field to either ACTIVATE or DISCARD.

Therefor, I tried to do the following:

  1. First get the sandbox Id from Production, via a query.
  2. One I had the Id, try to execute a HTTP PATCH method (which is available according to the documentation referenced above):

Endpoint:

/services/data/v42.0/tooling/sobjects/SandboxInfo/

Payload:

{
  "AutoActivate": true,
  "Id": "0GQ58000000TQacGAG"
}

But the response I get is the following:

[ { "errorCode" : "METHOD_NOT_ALLOWED", "message" : "HTTP Method 'PATCH' not allowed. Allowed are HEAD,GET,POST" } ]

Is there something I'm doing wrong? How is the update supposed to be done?

4

PATCH methods use the ID in the URL; if you put it in the body, it simply won't work.

Here's how it should look:

/services/data/v42.0/tooling/sobjects/SandboxInfo/0GQ58000000TQacGAG

{
  "AutoActivate": true
}

Using the URL you're trying: /services/data/v42.0/tooling/sobjects/SandboxInfo, you're actually hitting an "insert" URL (you would use this to create a new SandboxInfo).

You can try this out with something like an Account or another type of record to experiment without creating new sandboxes.

5
  • Man, you're guiding me through the whole Tooling API adventure hahaha. Thanks! :) Apr 15 '18 at 12:06
  • @JavierGarcíaManzano No problem! Always glad to help.
    – sfdcfox
    Apr 15 '18 at 12:09
  • Update to that answer: you also need to specify the license type in the request body like this: "LicenseType": "DEVELOPER"
    – POZ
    Feb 25 '20 at 12:23
  • If your user doesn't have °Modify All Data" permission it will not work, unfortunately: trailblazer.salesforce.com/issues_view?id=a1p4V000001SpyaQAC Jan 6 '21 at 9:03
  • @ThiagoBarcala I'm somehow not surprised that this happened. The Tooling API itself requires Modify All Data to do almost anything with it. However, that's definitely a bug, and I'm sure that Salesforce will fix this. Thanks for the heads-up!
    – sfdcfox
    Jan 6 '21 at 14:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.