Skip to content

Scene executes successfully via curl but not via Google Apps Script (GAS) despite receiving success response #458

@hrcr367

Description

@hrcr367

Current Situation

When executing a scene via Google Apps Script (GAS), the API returns a success response (statusCode: 100, message: "success"), but the scene does not actually execute. The same scene executes correctly when using curl from the command line.

  • curl: Scene executes, appears in app history as "Scene Name OpenAPI"
  • GAS: Returns success response, but scene does NOT execute, NO history in app

I have tried both API v1.0 and v1.1 with the same result.

Logs

curl command (WORKS):
curl -H "Authorization:<token>" -X POST "https://api.switch-bot.com/v1.0/scenes/<scene_id>/execute"

Response: {"statusCode":100,"body":{},"message":"success"}
Result: Scene executes, history shows in app ✓

Google Apps Script (DOES NOT WORK):
function executeSwitchBotScene() {
  const url = "https://api.switch-bot.com/v1.0/scenes/<scene_id>/execute";
  const options = {
    method: "POST",
    headers: {
      "Authorization": "<token>",
      "Accept": "*/*"
    },
    contentType: "application/json; charset=utf-8",
    payload: "",
    muteHttpExceptions: true
  };
  const response = UrlFetchApp.fetch(url, options);
  Logger.log("Status: " + response.getResponseCode());
  Logger.log("Response: " + response.getContentText());
}

Response: {"statusCode":100,"body":{},"message":"success"}
Result: Scene does NOT execute, no history in app ✗

Also tried v1.1 API with HMAC-SHA256 signature - same issue (success response but no execution).

Configuration

- API Version: Tested both v1.0 and v1.1
- Endpoint: /scenes/{sceneId}/execute
- Authentication: Token (v1.0) / Token + HMAC-SHA256 signature (v1.1)

Environment

  • Client: Google Apps Script (UrlFetchApp)
  • Working client: curl 8.16.0 on Windows
  • SwitchBot App: Latest version

Additional Context

The API returns identical success responses for both curl and GAS requests, but only curl actually triggers the scene execution. This suggests the API may be validating something beyond the standard response (User-Agent? Request origin? Other headers?) that causes GAS requests to be silently ignored despite returning success.

Is there any difference in how requests from different clients are processed? Are there any additional headers or requirements that might not be documented?

Metadata

Metadata

Labels

questionFurther information is requested

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions