title: How do I communicate between Unity and an aws lambda function?
body: <p>I have a working <code>UnityWebRequest</code> in Unity...</p>
  
  <pre><code>private static void SendMessageToServerless(MessageBase message) {
      string uri = "https://urigoeshere.com/test";
  
      Get(uri, message);
  }
  
  private static void Get(string uri, MessageBase message) {
      instance.StartCoroutine(GetRequest(uri, message));
  }
  
  private static IEnumerator GetRequest(string uri, MessageBase message) {
      // TODO: Do something with message
      UnityWebRequest webRequest = UnityWebRequest.Get(uri);
      yield return webRequest.SendWebRequest();
  
      Debug.Log(webRequest.downloadHandler.text);
  }
  </code></pre>
  
  <p>... and separately I have a working C# lambda on AWS ...</p>
  
  <pre><code>[assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.Json.JsonSerializer))]
  namespace SwordPlayServerless {
      public class Function {
          public string FunctionHandler(string input, ILambdaContext context) {
              return "Hello " + input;
          }
      }
  }
  </code></pre>
  
  <p>... however I'm not sure how to bridge the gap and send typed content from one to the other. I commonly get the following error message in reply:</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.",
    ...
  </code></pre>