aws / aws-sdk-js

AWS SDK for JavaScript in the browser and Node.js
https://aws.amazon.com/developer/language/javascript/
Apache License 2.0
7.59k stars 1.55k forks source link

polly: Unexpected token < in JSON at position 0 #1353

Closed klinquist closed 7 years ago

klinquist commented 7 years ago

I'm trying to use AWS Polly - the exact example provided in the docs:

    var params = {
        OutputFormat: "mp3",
        SampleRate: "8000",
        Text: "All Gaul is divided into three parts",
        TextType: "text",
        VoiceId: "Joanna"
    };
    polly.synthesizeSpeech(params, function (err, data) {
        cb(err, data)
    });

I'm getting an error into the callback:
{"message":"Unexpected token < in JSON at position 0","code":"SyntaxError","time":"2017-02-09T18:38:06.459Z","statusCode":400,"retryable":false,"retryDelay":26.743564588273294}

Using the latest aws-sdk.

chrisradek commented 7 years ago

@klinquist In the callback you provide to synthesizeSpeech, can you log this.httpResponse.body.toString()?

chrisradek commented 7 years ago

@klinquist It might also be helpful to log this.httpResponse.headers. The body should be a Buffer if the operation succeeds.

Is this happening intermittently? I just ran the operation with the exact same parameters in us-east-1 and node 6.9.1. Can you share your environment details and region?

klinquist commented 7 years ago

us-west-2, node 6.9.4. OS X. Not intermittent - happens every time.

image

klinquist commented 7 years ago

body toString is ```this.httpResponse.body.toString() "<?xml version="1.0" encoding="UTF-8"?>

AuthorizationHeaderMalformedThe authorization header is malformed; the region 'us-west-2' is wrong; expecting 'us-east-1'us-east-163F538FBA8496F6CUXa+AHXPijKFkuitMtbi8Cc9Zy3edUSp6Y0E+gx/hVHZi44aZKuJUtH6Z2emPc8z/dBW7xFQntM="``` Looks like I need to use us-east-1?
klinquist commented 7 years ago

Aah - nevermind. Looks like my AWS.config was setting the endpoint (used the same config as I was using for an s3 api call).

lock[bot] commented 4 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.