Log Insight API and JSON no content to map due to end-of-input

While you will not see the error in the title of this blog post in the Log Insight UI, you may see it when issuing API calls to Log Insight and may also see it in the Log Insight runtime.log. What is it, what does it mean, and how do you fix it? Read on to learn more!

li-logo

The error means that you have a malformed JSON request. The key bit is “JSON”. The Log Insight API is based on JSON and you must ensure that you pass the Content-Type header with application/json. If you do not, then by default the Content-Type header will be set to application/x-www-form-urlencoded and you will receive the following error:

JSON: No content to map due to end-of-input

Now, it is possible to have an unintentionally malformed API request. Let’s say you have a shell script like the following:

IMPORTANT: Do not run curl with the -s flag or the errors will not be reported!

If you run this code then you would receive the following output:

Notice how the first line contains an error. This is because of the HEADERS variable. If you wrap the HEADERS variable in double quotations then it works as expected:

While the header is the most common reason to see this error, if any other part of the API request is malformed you may experience this error as well. I hope this helps!

© 2016, Steve Flanders. All rights reserved.

Leave a Reply