1

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?

2

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.

  • Man, you're guiding me through the whole Tooling API adventure hahaha. Thanks! :) – Javier García Manzano Apr 15 '18 at 12:06
  • @JavierGarcíaManzano No problem! Always glad to help. – sfdcfox Apr 15 '18 at 12:09

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.