"Unknown device" on Image Server API connect

When I attempt to connect to the Image Server API, I get the following XML back:

<methodresponse>
  <requestid>1</requestid>
  <methodname>connect</methodname>
  <connected>no</connected>
  <errorreason>Unknown device</errorreason>
  <includehasmotionflags>no</includehasmotionflags>
  <includesequencenumber>no</includesequencenumber>
  <includesignatures>no</includesignatures>
  <alwaysstdjpeg>no</alwaysstdjpeg>
  <transcode>
    <allframes>no</allframes>
  </transcode>
  <clientcapabilities>
    <privacymask>no</privacymask>
    <privacymaskversion>0</privacymaskversion>
    <multipartdata>no</multipartdata>
    <datarestriction>no</datarestriction>
  </clientcapabilities>
  <servercapabilities>
    <connectupdate>yes</connectupdate>
    <signatures>yes</signatures>
    <adaptivestreamingversion>1</adaptivestreamingversion>
  </servercapabilities>
</methodresponse>

I see that “Unknown device” is the problem, but what does that mean? Unknown camera GUID? Unknown connection GUID? Both are correct: the camera ID is returned from the Server Command API call that gets configuration info; and the connection GUID is what I provide as the instance ID when I make the login request and get the token back.

I’ve been looking through the TcpVideoViewer code and discovered that the ID in is actually the camera ID again. I’m not sure why this should need to be provided twice, but when I use that instead of the instance ID I get a successful response.

I think the Image Server API needs a bit of a review: there seems to be quite a lot in there that isn’t entirely logical, like having to include the username and password elements even though they are ignored by the server, and like having to use \r\n for newlines, and (apparently) having to get the parameters in the right order, and not being allowed any line breaks in the XML…