title: Testing alexa skill returns "Error converting the Lambda event JSON payload to a string"
body: <p>I'm attempting to make an Alexa device speak a string of text that I return from my Lambda function written in C#.</p>
  
  <p>Right now I've written a basic method which returns a string.</p>
  
  <pre><code>[assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.Json.JsonSerializer))]
  
  namespace AlexaTeachMeNewWord
  {
      public class Function
      {
          public string FunctionHandler(object input, ILambdaContext context)
          {
              return "Hello this is a test";
          }
      }
  }
  </code></pre>
  
  <p>Using the AWS toolkil for Visual Studio 2019, if I test the function with the example Alexa invocation, the string of text is clearly returned.</p>
  
  <p><a href="https://i.stack.imgur.com/VusjX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VusjX.png" alt="Alexa skill test"></a></p>
  
  <p>However once I've published the function to AWS Lambda, I get the below error telling me <code>Error converting the Lambda event JSON payload to a string</code></p>
  
  <pre><code>{
    "errorType": "JsonSerializerException",
    "errorMessage": "Error converting the Lambda event JSON payload to a string. JSON strings must be quoted, for example \"Hello World\" in order to be converted to a string: Unexpected character encountered while parsing value: {. Path '', line 1, position 1.",
    "stackTrace": [
      "at Amazon.Lambda.Serialization.Json.JsonSerializer.Deserialize[T](Stream requestStream)",
      "at lambda_method(Closure , Stream , Stream , LambdaContextInternal )"
    ],
    "cause": {
      "errorType": "JsonReaderException",
      "errorMessage": "Unexpected character encountered while parsing value: {. Path '', line 1, position 1.",
      "stackTrace": [
        "at Newtonsoft.Json.JsonTextReader.ReadStringValue(ReadType readType)",
        "at Newtonsoft.Json.JsonTextReader.ReadAsString()",
        "at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.ReadForType(JsonReader reader, JsonContract contract, Boolean hasConverter)",
        "at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)",
        "at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)",
        "at Newtonsoft.Json.JsonSerializer.Deserialize[T](JsonReader reader)",
        "at Amazon.Lambda.Serialization.Json.JsonSerializer.Deserialize[T](Stream requestStream)"
      ]
    }
  }
  </code></pre>
  
  <p>This is confusing since i'm not trying to return a JSON payload.</p>