Skip to content

[BUG] - Custom-variable API stores entire JSON body instead of extracting "value" field #92

Description

@tom-niddatal

Make sure you have updated to the latest version of the module

  • I have checked this on the latest version of the module

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Description
When setting a custom variable via the HTTP API, Companion does not parse the JSON body correctly.
Instead of extracting the value field, the API stores the entire JSON body as a string.

This happens both when using Companion’s internal HTTP module and when sending requests from external clients such as PowerShell or curl.

Expected Behavior
A POST request like:

Code
POST /api/custom-variable/Testvar/value
Content-Type: application/json

{"value":"Tommy"}
should store only:

Code
Tommy
in the custom variable.

Actual Behavior
Companion stores the entire JSON body:

Code
{"value":"Tommy"}
The API still returns 200 OK with the body ok.

Steps to Reproduce
Create a custom variable named Testvar.

Send the following request:

PowerShell
powershell
Invoke-WebRequest -Uri "http://<IP>:8888/api/custom-variable/Testvar/value"
-Method POST -Headers @{ "Content-Type" = "application/json" }
-Body '{"value":"Tommy"}'
Read the variable:

Code
GET /api/custom-variable/Testvar/value
The result is:

Code
{"value":"Tommy"}
instead of:

Code
Tommy
Additional Observations
Sending a plain text body ("Tommy") results in the API returning "No value", which confirms that JSON is required.

This means the API expects JSON but does not parse it.

The issue is independent of the client.
The same behavior occurs with:

Companion’s internal HTTP module (httpx)

PowerShell

curl

Environment
Companion Master

API port: 8888

Custom-variable API endpoint: /api/custom-variable//value

Suspected Cause
The API handler appears to store the raw request body instead of extracting body.value.
Likely something equivalent to:

js
store(body)
instead of:

js
store(body.value)

Environment

- OS: Win11
- Browser: Edge
- Companion Version: 4.3
- Module Version: -----------     (4.3)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions