#Bug report: VTS Event Subscription request returns JSON error when timestamp is null

31 messages · Page 1 of 1 (latest)

quasi osprey
#

Sending the following request:

{
  "apiName":"VTubeStudioPublicAPI",
  "apiVersion":"1.0",
  "timestamp":null,
  "messageType":"EventSubscriptionRequest",
  "requestID":"5880d7b0-eabc-4210-9fbb-2ea43da99be3",
  "data":{
    "eventName":"ModelLoadedEvent",
    "subscribe":true,
    "config":{}
  }
}

Returns the following:

"data":{"errorID":2,"message":"JSON payload error. Please check the documentation."}

However, removing the timestamp, as so:

{
  "apiName":"VTubeStudioPublicAPI",
  "apiVersion":"1.0",
  "messageType":"EventSubscriptionRequest",
  "requestID":"cfc1901a-73a9-45fe-b96c-500653965470",
  "data":{
    "eventName":"ModelLoadedEvent",
    "subscribe":true,
    "config":{}
  }
}

Returns successfully:

"data":{"subscribedEventCount":1,"subscribedEvents":["ModelLoadedEvent"]}

This isn't the case for any other API request I've used

quasi osprey
#

Bump

vapid glacier
#

Timestamps aren't part of the request payload.

#

No request payload should contain that field.

#

For parts of the events API, I'm using a different JSON deserializer than the rest of the API. And that one may fail when unknown fields are provided in the payload.

#

That's probably why adding the field in the normal API doesn't break stuff but does so in the events API.

#

I know that's a bit inconsistent, but as long as your payloads are correct, you won't have to worry about it.

quasi osprey
#

I see. I guess the reason I made the mistake is because the request was so similar to the standard API, I assumed they were the same.

It might then be worth adding it as an optional but unused field or a separate error message (to prevent cases such as mine), as otherwise the requests are nearly identical; or adding the timestamp functionality, as it may be helpful for a future developer to know when the subscription completed for timing reasons (though that doesn't apply to my case)

#

Oh, I see the timestamp does already exist facepalm

#

Of course, else deserialisation would have failed on my side

#

Adding it as an unused field would allow the same serialiser to work for both normal and event requests on the client side

vapid glacier
#

But I'm still not sure why you're sending in a timestamp in the first place.

#

There's no request payload anywhere that has a timestamp field.

#

Only the response payloads have timestamps.

quasi osprey
#

In C#, I'm serialising to and from a single class that handles both requests and responses using Newtonsoft.

The timestamp is nullable and not set for requests, but the default behaviour for Newtonsoft is to include null values in serialized payloads. I've worked around it by configuring the serializer to have the opposite behaviour, ignoring null values

vapid glacier
#

I see NOTED

#

I can make that change. Can't say when the next API update will be though.

#

Either way, thanks for reporting.

#

(I put it on the trello)

quasi osprey
#

No rush for me, since I already have a workaround. Thanks Denchi!

vapid glacier
#

Closing this unless there's something else.

quasi osprey
#

Please do close 😄

quasi osprey
#

This is still busted ;-;

Request with timestamp (beautified from the minified originals):

{
    "apiName": "VTubeStudioPublicAPI",
    "apiVersion": "1.0",
    "timestamp": null,
    "messageType": "EventSubscriptionRequest",
    "requestID": "aa3abe71-351c-4fe5-9207-180b84696c61",
    "data": {
        "eventName": "TestEvent",
        "subscribe": true,
        "config": {
            "testMessageForEvent": "Beep boop!"
        }
    }
}

{
    "apiName": "VTubeStudioPublicAPI",
    "apiVersion": "1.0",
    "timestamp": 1685662001364,
    "messageType": "APIError",
    "requestID": "aa3abe71-351c-4fe5-9207-180b84696c61",
    "data": {
        "errorID": 2,
        "message": "JSON payload error. Please check the documentation."
    }
}

Request without timestamp:

{
    "apiName": "VTubeStudioPublicAPI",
    "apiVersion": "1.0",
    "messageType": "EventSubscriptionRequest",
    "requestID": "aa3abe71-351c-4fe5-9207-180b84696c61",
    "data": {
        "eventName": "TestEvent",
        "subscribe": true,
        "config": {
            "testMessageForEvent": "Beep boop!"
        }
    }
}

{
    "apiName": "VTubeStudioPublicAPI",
    "apiVersion": "1.0",
    "timestamp": 1685662027105,
    "messageType": "EventSubscriptionResponse",
    "requestID": "aa3abe71-351c-4fe5-9207-180b84696c61",
    "data": {
        "subscribedEventCount": 1,
        "subscribedEvents": [
            "TestEvent"
        ]
    }
}
#

Running v1.26.6 from the public beta branch

vapid glacier
#

@quasi osprey I'll check again. Maybe I uploaded the wrong version. Payloads with null-timestamps work for me now.

vapid glacier
#

@quasi osprey Should work now.

#

Update to the newest beta (it's still 1.26.6 though)

quasi osprey
#

Forgot to reply to this