title: aws lambda: invoke with payload from cli
body: <p>I'm trying to invoke my lambda using aws cli:</p>
  
  <pre><code>$ aws lambda invoke \
      --function-name soc-update-dynamodb-java \
      --invocation-type Event \
      --payload file://invoke-payload.json \
     response.json
  </code></pre>
  
  <p>However, I'm getting this message:</p>
  
  <blockquote>
    <p>An error occurred (InvalidRequestContentException) when calling the Invoke operation: Could not parse request body into json: Invalid UTF-8 middle byte 0x28
     at [Source: (byte[])"E�(�����U�슉���ޞԨ��k.....</p>
  </blockquote>
  
  <p><code>payload.json</code> content is a s3 event-like json:</p>
  
  <pre><code>{
  "Records": [
    {
      "eventVersion": "2.0",
      "eventSource": "aws:s3",
      "awsRegion": "eu-central-1",
      "eventTime": "1970-01-01T00:00:00.000Z",
      "eventName": "ObjectCreated:Put",
      "userIdentity": {
        "principalId": "EXAMPLE"
      },
      "requestParameters": {
        "sourceIPAddress": "127.0.0.1"
      },
      "responseElements": {
        "x-amz-request-id": "EXAMPLE123456789",
        "x-amz-id-2": "EXAMPLE123/5678abcdefghijklambdaisawesome/mnopqrstuvwxyzABCDEFGH"
      },
      "s3": {
        "s3SchemaVersion": "1.0",
        "configurationId": "testConfigRule",
        "bucket": {
          "name": "soc-connect",
          "ownerIdentity": {
            "principalId": "EXAMPLE"
          },
          "arn": "arn:aws:s3:::example"
        },
        "object": {
          "key": "example.key",
          "size": 1024,
          "eTag": "0123456789abcdef0123456789abcdef",
          "sequencer": "0A1B2C3D4E5F678901"
        }
      }
    }
  ]
  }
  </code></pre>
  
  <p>I'm able to execute it from aws web console using this event, but I have problem trying to invoke it using aws cli.</p>
  
  <p>I've get encoding from invoke-payload.json:</p>
  
  <pre><code>$ file -i invoke-payload.json 
  invoke-payload.json: text/plain; charset=us-ascii
  </code></pre>
  
  <p>As you can see, encoding is <code>us-ascii</code>.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I've also tried to send payload embedded on command. As you can see on image, I'm getting the same message:</p>
  
  <p><a href="https://i.stack.imgur.com/4BMLQ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/4BMLQ.png" alt="enter image description here"></a></p>
  
  <p>Any ideas?</p>