Title: SageMaker Javascript SDK Endpoint Invocation Error: "CustomerError: Unable to parse payload to numeric values"
Tags: javascript;node.js;aws-sdk;amazon-sagemaker
Question: I was invoking the SageMaker endpoint from my angular front-end when I came across this error on AWS CloudWatch regarding my model making inferences from the data (In the form of a comma-separated string with target values at the first index) I was sending : Unable to parse numeric values. The string I'm using to invoke the endpoint was : "1533071820,0.05619,0.05619,0.05611,0.05611,0.006076\n"
String request = "1533071820,0.05619,0.05619,0.05611,0.05611,0.006076\n"
ByteBufferbuf = ByteBuffer.wrap(request.getBytes());
invokeEndpointRequest.setBody(buf);
Use the SageMaker API
AmazonSageMakerRuntime amazonSageMaker = AmazonSageMakerRuntimeClientBuilder.defaultClient();
Invoke the model endpoint on SageMaker
InvokeEndpointResult invokeEndpointResult = amazonSageMaker.invokeEndpoint(invokeEndpointRequest);
The result I was expecting from the endpoint is a JSON object with the 'score' attribute in the format : {"predictions": [{"score": xxxxxxx}]}
I am getting a 'ModelError: Unable to evaluate payload' from the IDE logs and 'Unable to parse numeric values on CloudWatch'


Here is another answer: So, upon debugging this issue, I found that because of the newline character at the end, the model was assuming there are 2 strings in my input but there's only one. Hence, the error. So I just changed the string to : "1533071820,0.05619,0.05619,0.05611,0.05611,0.006076". And if I'm parsing more than one payload(batch), it's: "1533071820,0.05619,0.05619,0.05611,0.05611,0.006076\n1533071820,0.05619,0.05619,0.05611,0.05611,0.006076" where my 2 inputs are separated by that newline character and more importantly, there's no newline character at the end

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2019:00:01/16/19', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<javascript><node.js><aws-sdk><amazon-sagemaker>', 'Title': 'SageMaker Javascript SDK Endpoint Invocation Error: "CustomerError: Unable to parse payload to numeric values"', 'ViewCount': 305, 'id': 54216797, 'user_AboutMe': None, 'user_AccountId': 6790244.0, 'user_DisplayName': 'soymosaic', 'user_Reputation': 29.0, 'user_Views': 6.0, 'user_id': 5227646.0}}