title: SageMaker: An error occurred (ModelError) when calling the InvokeEndpoint operation: unable to evaluate payload provided
body: <p>I have a endpoint in Amazon SageMaker (Image-classification algorithm) in Jupyter notebook that works fine. In Lambda function works fine too, when I call the Lambda function from API Gateway, from test of API Gateway, works fine too.</p>
  <p>The problem is when I call the API from Postman according this answer: <a href="https://stackoverflow.com/questions/39660074/post-image-data-using-postman">&quot;Post Image data using POSTMAN&quot;</a></p>
  <p>The code in Lambda is:</p>
  <pre><code>import boto3
  import json
  import base64
  
  ENDPOINT_NAME = &quot;DEMO-XGBoostEndpoint-Multilabel&quot;
  runtime= boto3.client(&quot;runtime.sagemaker&quot;)
  imagen_ = &quot;/tmp/imageToProcess.jpg&quot;
  
  def write_to_file(save_path, data):
      with open(save_path, &quot;wb&quot;) as f:
          f.write(base64.b64decode(data))
  
  def lambda_handler(event, context):
      img_json = json.loads(json.dumps(event))
  
      write_to_file(imagen_, json.dumps(event, indent=2))
  
      with open(imagen_, &quot;rb&quot;) as image:
          f = image.read()
          b = bytearray(f)
  
      payload = b
  
      response = runtime.invoke_endpoint(EndpointName=ENDPOINT_NAME,
                                         ContentType=&quot;application/x-image&quot;,
                                         Body=payload)
  
      #print(response)
      result = json.loads(response[&quot;Body&quot;].read().decode())
      print(result)
      predicted_label=[]
      classes = [&quot;chair&quot;, &quot;handbag&quot;, &quot;person&quot;, &quot;traffic light&quot;, &quot;clock&quot;]
      for idx, val in enumerate(classes):
          print(&quot;%s:%f &quot;%(classes[idx], result[idx]), end=&quot;&quot;)
          predicted_label += (classes[idx], result[idx])
  
      return {
        &quot;statusCode&quot;: 200,
        &quot;headers&quot;: { &quot;content-type&quot;: &quot;application/json&quot;},
        &quot;body&quot;:  predicted_label
  }
  </code></pre>
  <p>The error is:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;/var/task/lambda_function.py&quot;, line 26, in lambda_handler
      Body=payload)
    File &quot;/var/runtime/botocore/client.py&quot;, line 316, in _api_call
      return self._make_api_call(operation_name, kwargs)
    File &quot;/var/runtime/botocore/client.py&quot;, line 626, in _make_api_call
      raise error_class(parsed_response, operation_name)
  botocore.errorfactory.ModelError: An error occurred (ModelError) when calling the InvokeEndpoint operation: Received client error (400) from model with message &quot;unable to evaluate payload provided&quot;. See https://us-east-2.console.aws.amazon.com/cloudwatch/home?region=us-east-2#logEventViewer:group=/aws/sagemaker/Endpoints/DEMO-XGBoostEndpoint-Multilabel in account 866341179300 for more information. ```
  </code></pre>