Switch PUT request to ASCOM Alpaca switch has non-conformant ID in PUT request body

Issue #1252 resolved
Geoff Stone created an issue

Reproducible: YES

Description:

When doing a PUT to set a switch state the x-www-form-encoded is non-conformant and some switches refuse the command with a 400. The software is sending the id in the body as ‘ID=' instead of ‘Id=’ - all caps instead of ‘Id’ which is correct. The Alpaca OmniSimulator rejects these switch PUT commands with a 400 status. There is no error indication in NINA other than the switch does not change state.

Here’s the output from the Omni-Simulators:

09/12/2023 06:13:25 [Error] - A data validation error occurred for request /api/v1/switch/0/setswitch with error message <The ID field is required.>. See https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.1.
09/12/2023 06:14:13 [Warning] - Incorrect capitalization on optional key Id, received ID
09/12/2023 06:14:13 [Error] - Error on request /api/v1/switch/0/setswitchvalue with details: The API Form is required to match the Alpaca Specification. Bad Form Key Capitalization(s): Id, received: I

I’ve verified this is the problem using Postman to send a properly formatted PUT request.

To Reproduce:

Install and run the ASCOM Omni-Simulator: https://github.com/ASCOMInitiative/ASCOM.Alpaca.Simulators

Set NINA to use the switch device ASCOM Remote Client

Connect to the switch

Try to change a switch state - omniswitch console log will show the error as above. The switch state will not change.

Expected behavior:

The switch state should change as requested

Actual Behavior:

The switch state doesn’t change and there is no apparent error indication. The HTTP PUT request fails with 400 status.

How to Fix:

In the PUT request body there should be something like ‘Id=0&State=true' - ‘Id’ and not ‘ID’ in all caps.

Changing the id from ‘ID’ to ‘Id’ in the PUT request body fixes it.

Comments (4)

  1. Stefan B repo owner

    Hi,

    thank you for your report.

    As there is no Alpaca specific implementation in N.I.N.A. this call is managed by the ASCOM remote client. This needs to be fixed there. N.I.N.A. just sends the values to the underlying ASCOM interfaces.

  2. Log in to comment