title: Amazon Lambda in C# - JsonReaderException
body: <p>I am attempting to write an AWS Lambda function in C#.  I have the AWS Toolkit for Visual Studio 2015.  I created a project with the AWS Lambda Project (.Net Core) and then selected the Empty Function option.  Which gave me the following code:</p>
  
  <p><strong>UPDATE &amp; ANSWER 02/24/17</strong> - The comment marked as the Answer was useful knowledge but was not the actual answer for me.  It was <em>@PavelSafronov</em>'s comment in that answer that did the trick.  I was either passing nothing in (and getting the error) or I assumed it wanted ME to give the information in JSON format so I would enter <code>{ "input": "Some string" }</code> and still get the error.  Now that I just passed in "Some string" it worked.  <strong>However</strong>, as far as I am concerned, this seems like a bug.  A <code>string</code> is by default <code>nullable</code> and the code <em>written by Amazon</em> even assumes it could be by virtual of the <code>input?.ToUpper()</code> where the <code>?.</code> is checking for <code>null</code>.</p>
  
  <p><strong>Note:</strong> <em>I added the <code>LambdaLogger.Log</code> lines and the <code>Constructor</code> to see where I was getting</em>:</p>
  
  <pre><code>using Amazon.Lambda.Core;
  using Amazon.Lambda.Serialization.Json;
  
  // Assembly attribute to enable the Lambda function's JSON input to be converted into a .NET class.
  [assembly: LambdaSerializer(typeof(JsonSerializer))]
  
  namespace AWSLambdaTest1 {
  
    public class Function {
  
      public Function() {
        LambdaLogger.Log("Within the Constructor");
      }
  
      public string KevinsTestFunction(string input, ILambdaContext context) {
        LambdaLogger.Log("Within the KTF");
        return input?.ToUpper();
      }
  
    }
  }
  </code></pre>
  
  <p>The output screen and Solution Explorer were saying:</p>
  
  <pre><code>Errors in C:\Test Projects\AWSLambda1\AWSLambda1\AWSLambda1.xproj
    Unable to resolve 'Amazon.Lambda.Core (&gt;= 1.0.0)' for '.NETCoreApp,Version=v1.0'.
  </code></pre>
  
  <p>However, this will build and publish to AWS without fail.  I can even Invoke it which returns the following - <strong>And is my main question</strong>:</p>
  
  <pre><code>{
    "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 lambda_method(Closure , Stream , Stream , ContextInfo )"
    ]
  }
  </code></pre>
  
  <p>The Log file showed that the <code>Constructors</code> log message got there but NOT the actual <code>KevingsTestFunction</code> log message.</p>
  
  <p>On a side note, I am able to get the <code>Unable to resolve 'Amazon.Lambda.Core (&gt;= 1.0.0)' for '.NETCoreApp,Version=v1.0'</code> error to go away by adding the following to my <code>project.json</code> file:</p>
  
  <pre><code>"runtimes": {
    "win10-x64": {},
    "win81-x64": {},
    "win8-x64": {},
    "win7-x64": {}
  }
  </code></pre>
  
  <p>Which makes sense on a Windows machine, not so much here on Amazon.  Do I need some different <code>runtime(s)</code>?</p>
  
  <p>That change did not change the <code>JsonReaderException</code> exception.</p>
  
  <p>I tried adding <code>"Linux": {}</code> but that made no change either.</p>
  
  <p>I even tried to update the NuGet package <code>Microsoft.NETCore.App</code> from <code>1.0.0</code> to <code>1.1.0</code> and that did nothing as well and even back to <code>1.0.1</code>.</p>
  
  <p>I would figure the default example they give you would work, but I am wrong there.  It seems like there are issues with the <code>Amazon.Lambda.Serialization.Json.JsonSerializer</code> attribute.  Is it possible to just use <code>NewtonSoft</code>?</p>