title: Sagemaker : How do I set content_type in Predictor (Sagemake > 2.0)?
body: <p>Requesting assistance with the following error.</p>
  <blockquote>
  <p>An error occurred (ModelError) when calling the InvokeEndpoint
  operation: Received client error (415) from model with message
  &quot;Content-type application/octet-stream not supported. Supported
  content-type is text/csv, text/libsvm&quot;</p>
  </blockquote>
  <p>Here is the relevant code -</p>
  <pre><code>from sagemaker import image_uris
  from sagemaker.estimator import Estimator
  
  xgboost_hyperparameters = {
          &quot;max_depth&quot;:&quot;5&quot;,
          &quot;eta&quot;:&quot;0.2&quot;,
          &quot;gamma&quot;:&quot;4&quot;,
          &quot;min_child_weight&quot;:&quot;6&quot;,
          &quot;subsample&quot;:&quot;0.7&quot;,
          &quot;num_round&quot;:&quot;50&quot;
  }
  
  xgboost_image = image_uris.retrieve(&quot;xgboost&quot;, boto3.Session().region_name, version=&quot;1&quot;)
  
  
  
  estimator = Estimator(image_uri = xgboost_image,
                       hyperparameters = xgboost_hyperparameters,
                       role = role,
                       instance_count=1, 
                       instance_type='ml.m5.2xlarge', 
                        output_path= output_loc,
                       volume_size=5 )
  
  from sagemaker.serializers import CSVSerializer
  from sagemaker.deserializers import CSVDeserializer
  
  train_input = sagemaker.inputs.TrainingInput(s3_data = train_loc, content_type='text/csv',s3_data_type = 'S3Prefix')
  valid_input = sagemaker.inputs.TrainingInput(s3_data = validation_loc, content_type='text/csv',s3_data_type = 'S3Prefix')
  
  estimator.CONTENT_TYPE = 'text/csv'
  estimator.serializer = CSVSerializer()
  estimator.deserializer = None
  
  estimator.fit({'train':train_input, 'validation': valid_input})
  
  # deploy model with data config
  from sagemaker.model_monitor import DataCaptureConfig
  from time import gmtime, strftime
  s3_capture_upload_path = 's3://{}/{}/monitoring/datacapture'.format(bucket, prefix)
  model_name = 'project3--model-' + strftime(&quot;%Y-%m-%d-%H-%M-%S&quot;, gmtime())
  endpoint_name = 'project3-endpoint'
  data_capture_configuration = DataCaptureConfig(
                          enable_capture = True,
                          sampling_percentage=100,
                          destination_s3_uri=s3_capture_upload_path  )
  
  deploy = estimator.deploy(initial_instance_count = 1,
                            instance_type = 'ml.m4.xlarge'    ,
                            data_capture_config=data_capture_configuration,
                            model_name=model_name,
                            endpoint_name = endpoint_name
                           )
  </code></pre>
  <p>Then I face the error in the <em>Predictor</em></p>
  <pre><code>from sagemaker.predictor import Predictor
  
  predictor = Predictor(endpoint_name=endpoint_name)
  with open('test.csv', 'r') as f:
      for row in f:
          print(row)
          payload = row.rstrip('\n')
          response = predictor.predict(data=payload[2:])
          sleep(0.5)
  print('done!')
   
  </code></pre>
  <p>I looked at these links but haven't found an answer</p>
  <ol>
  <li><a href="https://github.com/aws-samples/reinvent2019-aim362-sagemaker-debugger-model-monitor/blob/master/02_deploy_and_monitor/deploy_and_monitor.ipynb" rel="nofollow noreferrer">https://github.com/aws-samples/reinvent2019-aim362-sagemaker-debugger-model-monitor/blob/master/02_deploy_and_monitor/deploy_and_monitor.ipynb</a></li>
  <li><a href="https://stackoverflow.com/questions/57908395/how-can-i-specify-content-type-in-a-training-job-of-xgboost-from-sagemaker-in-py">How can I specify content_type in a training job of XGBoost from Sagemaker in Python?</a></li>
  <li><a href="https://github.com/aws/amazon-sagemaker-examples/issues/729" rel="nofollow noreferrer">https://github.com/aws/amazon-sagemaker-examples/issues/729</a></li>
  </ol>