Teamviewer API doesn't support chunked Transfer-Encoding

Hi there!

I'm working on writing an integration and discovered that the Teamviewer API doesn't support chunked Transfer-Encoding. You can reproduce this nicely with curl:

Reproduction:

Run curl with the following arguments with a valid authorization token:

curl -X POST -H "Content-Type: application/json" https://webapi.teamviewer.com/api/v1/meetings -d '{"instant": true}' -H 'Authorization: {validAuthorization}' -H 'Transfer-Encoding: chunked' -v

What happens:

{"error":"invalid_request","error_description":"No parameters given","error_code":1}

What should happen:

The endpoint should be able to decode chunked encoding, as it uis a HTTP standard. A reply should look something like this:

{
"id": "m12-345-678",
"participant_web_link": "https://go.teamviewer.com/m12-345-678"
}

Workaround

Using non-chunked ('buffered') transfer encoding works out of the box:

curl -X POST -H "Content-Type: application/json" https://webapi.teamviewer.com/api/v1/meetings -d '{"instant": true}' -H 'Authorization: Bearer 3006253-qG6l7QNl0oRwa8w2PycG' -v

-> Works as expected

More information:

You can find more information about chunked encoding here: https://en.wikipedia.org/wiki/Chunked_transfer_encoding

Why is this relevant, even if there is a workaround

There are at least some HTTP libraries that by default use the chunked encoding mode. This for me created quite a bit of debugging until I found out the exact reasonj why this was faling and I suppose it could be a problem others encounter in the future, too.

The following code, which uses the Apache HTTP Client Connector for Jersey (written in Java) i.e. will be susceptible to this error:

public Client provideClient(SslContextProvider contextProvider) {
ClientConfig config = new ClientConfig()
.connectorProvider(new ApacheConnectorProvider())
.property(ClientProperties.CONNECT_TIMEOUT, THIRTY_SECONDS)
.property(ClientProperties.READ_TIMEOUT, THIRTY_SECONDS);

try {
return new JerseyClientBuilder()
.withConfig(config)
.sslContext(contextProvider.getContext())
.build();
}
catch (GeneralSecurityException e) {
throw new RuntimeException(e);
}

For reference (maybe somebody else encounters this problem and wants to know the solution I found:

adding this line disabled the default behavior of sending chunked encoded http requests:

.property(ClientProperties.REQUEST_ENTITY_PROCESSING, BUFFERED);

 

Comments

  • mLipok
    mLipok Posts: 781 ⭐Star⭐

    At least this should be documented in TV API documentation.

    Regards,
    mLipok , AutoIt MVP