amazon-web-servicesamazon-sagemakerinference

SageMaker batchTransform MultiRecord error - Unable to parse data as JSON. Make sure the Content-Type header is set to "application/json"


I am trying to invoke sagemaker batch transform

Input file example.jsonl

{"number":"0060540745","brand_name":"XYZ","generic_keywords":"123"}
{"number":"0060540745","brand_name":"XYZ","generic_keywords":"123"}
{"number":"0060540745","brand_name":"XYZ","generic_keywords":"123"}

When i use batchStrategy as SingleRecord transform is working fine

When i try to change the batchStrategy as MultiRecord I start to get the error

Error

Unable to parse data as JSON. Make sure the Content-Type header is set to "application/json"

If you check my job configuration i already set my contentType as mentioned.

how do i fix this issue

I tried with below content types like

"application/json"

"application/jsonlines"

"application/x+jsonlines"

enter image description here


Solution

  • I think since you are setting to multirecord the input_fn has to be modified to handle jsonlines instead of json.