<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[POST requests in NetXMS REST API not working ({"error":46})]]></title><description><![CDATA[<p dir="auto">Dear NetXMS,</p>
<p dir="auto">I am currently trying to receive data from our NetXMS Server through the REST API.</p>
<p dir="auto">Logging in via the basic Authentication header works fine and GET requests to /objects.*, /alarms.*, /info or /predefinedgraphs endpoints returns proper data on valid and error messages on invalid requests.</p>
<p dir="auto">However, using POST requests on the /sessions and /summaryTable/adHoc endpoints results in {"error":46} responses, when adding a JSON object to the request.</p>
<p dir="auto">Omitting the JSON object results in an "Invalid argument" message.</p>
<p dir="auto">Digging through the sourcecode of the latest version (3.0.2329) and cross-checking with the Tomcat9 logs, I could find out that when <strong>not</strong> adding a JSON object to the request, the logging message in line 100 of <em>AbstractHandler.java</em> ("No POST data in call") is being printed and the method returns the expected error object.</p>
<p dir="auto">But: When a JSON object <strong>is</strong> added to the request, the debug message in line 105 ("POST: data = ") is <strong>not</strong> being printed, although it should be and the loglevel is set to "debug" (Other debug messages of the API are visible).</p>
<p dir="auto">The tomcat logs then state that the internal error is caused by a NullPointerException, so my assumption would be that either <em>new JsonRepresentation(entity)</em> or <em>.getJsonObject()</em> in line 104 of <em>AbstractHandler.java</em> return NULL, thus causing this exception.</p>
<p dir="auto">Is there anything special that I did not take into account or did I stumble upon a bug? (Stacktrace is attached as screenshot "tomcat9_stacktrace.png")</p>
<p dir="auto">Just as additional information: I am using Postman (note the missing "description" field in the response, as seen in the attached screenshot "postman_error_46.png") for testing, but I also tried with cURL, giving the same error.</p>
<p dir="auto">I would be glad, if you could help me with this  <img src="https://forum.netxms.org/assets/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=72b86a538fc" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" style="height:1.4em;width:auto;vertical-align:middle" title=":)" alt="🙂" /></p>
<p dir="auto">Kind regards,<br />
fbu</p>
<hr />
<p dir="auto"><img src="/assets/uploads/files/smf/0000000004877-tomcat9_stacktrace.png" alt="tomcat9_stacktrace.png" class="img-markdown  img-fluid" width="1980" height="1224" /></p>
<p dir="auto"><img src="/assets/uploads/files/smf/0000000004879-postman_error_46.png" alt="postman_error_46.png" class="img-markdown  img-fluid" width="1559" height="546" /></p>
]]></description><link>https://forum.netxms.org/topic/6230/post-requests-in-netxms-rest-api-not-working-error-46</link><generator>RSS for Node</generator><lastBuildDate>Fri, 13 Nov 2026 13:09:05 GMT</lastBuildDate><atom:link href="https://forum.netxms.org/topic/6230.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 17 Oct 2019 08:42:39 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to POST requests in NetXMS REST API not working ({"error":46}) on Tue, 22 Oct 2019 15:02:18 GMT]]></title><description><![CDATA[<p dir="auto">Now, for my final update:</p>
<p dir="auto">After some hours of digging, I found out that NGINX was the reason for the entire problem: It was not configured to pass the POST data to the proxied API server.</p>
<p dir="auto">Thus, there is no problem with the original API code - I guess that the scenario, as stated in my second update, may be related to the entity's content being empty, once it is read (Somewhere, I read about it being a stream, rather than a storage variable, but I'm not 100% sure about that)</p>
<p dir="auto">Anyway, I apologize for causing this false alarm and thank you for your support.</p>
<p dir="auto">Keep up the good work on this tool</p>
<p dir="auto">Best regards,<br />
fbu</p>
]]></description><link>https://forum.netxms.org/post/26809</link><guid isPermaLink="true">https://forum.netxms.org/post/26809</guid><dc:creator><![CDATA[fbu]]></dc:creator><pubDate>Tue, 22 Oct 2019 15:02:18 GMT</pubDate></item><item><title><![CDATA[Reply to POST requests in NetXMS REST API not working ({"error":46}) on Tue, 22 Oct 2019 11:49:17 GMT]]></title><description><![CDATA[<p dir="auto">Update #2:</p>
<p dir="auto">Based on my previous update, I tested a workaround solution, by simply instantiating the JSONObject, based on the text value returned by the entity:</p>
<p dir="auto"><em>JSONObject data = new JSONObject(entity.getText());</em></p>
<p dir="auto">This works perfectly fine for me, when bypassing the NGINX.</p>
<p dir="auto">I still don't know what the actual problem is, but it works like this for me - I only need to fix the problem related to NGINX.</p>
<p dir="auto">Thanks for your help, Victor. Hopefully the root cause of this problem can be determined.</p>
<p dir="auto">Kind regards,<br />
fbu</p>
]]></description><link>https://forum.netxms.org/post/26808</link><guid isPermaLink="true">https://forum.netxms.org/post/26808</guid><dc:creator><![CDATA[fbu]]></dc:creator><pubDate>Tue, 22 Oct 2019 11:49:17 GMT</pubDate></item><item><title><![CDATA[Reply to POST requests in NetXMS REST API not working ({"error":46}) on Tue, 22 Oct 2019 10:23:34 GMT]]></title><description><![CDATA[<p dir="auto">Quick update:</p>
<p dir="auto">Previously, I was using an NGINX in front of Tomcat9 for hostname and SSL/TLS handling.</p>
<p dir="auto">When bypassing that NGINX and going directly to the Tomcat, the <em>entity.getText()</em> actually returns the provided data as string. However, <em>new JsonRepresentation(endity).getJsonObject()</em> and <em>.getText()</em> still return NULL and cause the same NullPointerException, as before. (see attachment for debug messages)</p>
<p dir="auto">I am pretty much out of ideas, right now. I'll still try to at least get a similar result <strong>with</strong> using NGINX, as I will need it in the future, but this might just be a configuration error.</p>
<p dir="auto">Hope this helps.</p>
<p dir="auto">Kind regards,<br />
fbu</p>
<hr />
<p dir="auto"><img src="/assets/uploads/files/smf/0000000004891-bypass_nginx.png" alt="bypass_nginx.png" class="img-markdown  img-fluid" width="2756" height="201" /></p>
]]></description><link>https://forum.netxms.org/post/26807</link><guid isPermaLink="true">https://forum.netxms.org/post/26807</guid><dc:creator><![CDATA[fbu]]></dc:creator><pubDate>Tue, 22 Oct 2019 10:23:34 GMT</pubDate></item><item><title><![CDATA[Reply to POST requests in NetXMS REST API not working ({"error":46}) on Tue, 22 Oct 2019 08:15:06 GMT]]></title><description><![CDATA[<p dir="auto">Hi Victor,</p>
<p dir="auto">I managed to build the changed source code for the API and deploy it on tomcat. You can find the changes in the attachment "sourcecode_change.png" (lines 103 - 108).</p>
<p dir="auto">The debug-messages are printed in the screenshot "debug_messages.png". I shows that <em>entity.getText()</em> returns NULL, which causes the StringReader called by <em>getJsonObject()</em> (now in line 107) to throw a NullPointerException (as seen in "nullpointer_cause.png".</p>
<p dir="auto">However, I still don't know why getText() returns NULL in the first place ... I will keep searching for the cause, but I'm not feeling to optimistic about my chances.</p>
<p dir="auto">Hope, I could help, so far.</p>
<p dir="auto">Best regards,<br />
fbu</p>
<hr />
<p dir="auto"><img src="/assets/uploads/files/smf/0000000004885-sourcecode_change.png" alt="sourcecode_change.png" class="img-markdown  img-fluid" width="1409" height="570" /></p>
<p dir="auto"><img src="/assets/uploads/files/smf/0000000004887-debug_messages.png" alt="debug_messages.png" class="img-markdown  img-fluid" width="1857" height="562" /></p>
<p dir="auto"><img src="/assets/uploads/files/smf/0000000004889-nullpointer_cause.png" alt="nullpointer_cause.png" class="img-markdown  img-fluid" width="1719" height="340" /></p>
]]></description><link>https://forum.netxms.org/post/26806</link><guid isPermaLink="true">https://forum.netxms.org/post/26806</guid><dc:creator><![CDATA[fbu]]></dc:creator><pubDate>Tue, 22 Oct 2019 08:15:06 GMT</pubDate></item><item><title><![CDATA[Reply to POST requests in NetXMS REST API not working ({"error":46}) on Mon, 21 Oct 2019 07:02:03 GMT]]></title><description><![CDATA[<p dir="auto">Okay, I will try my best. Is there a way to only build the war file for the API, or do I need to rebuild the whole project?</p>
<p dir="auto">Kind regards,<br />
fbu</p>
]]></description><link>https://forum.netxms.org/post/26796</link><guid isPermaLink="true">https://forum.netxms.org/post/26796</guid><dc:creator><![CDATA[fbu]]></dc:creator><pubDate>Mon, 21 Oct 2019 07:02:03 GMT</pubDate></item><item><title><![CDATA[Reply to POST requests in NetXMS REST API not working ({"error":46}) on Fri, 18 Oct 2019 16:49:10 GMT]]></title><description><![CDATA[<p dir="auto">It looks very strange. Null pointer exception happens within tokenizer, that means that content getText() method returns null. If you can modify source and add additional logging for entity and entity.getText() that could help.</p>
<p dir="auto">Best regards,<br />
Victor</p>
]]></description><link>https://forum.netxms.org/post/26792</link><guid isPermaLink="true">https://forum.netxms.org/post/26792</guid><dc:creator><![CDATA[victor]]></dc:creator><pubDate>Fri, 18 Oct 2019 16:49:10 GMT</pubDate></item><item><title><![CDATA[Reply to POST requests in NetXMS REST API not working ({"error":46}) on Fri, 18 Oct 2019 15:20:57 GMT]]></title><description><![CDATA[<p dir="auto">Hi Victor,</p>
<p dir="auto">I added a screenshot of the stack trace for the NullPointerException. (Note that the date does not match, because I simply placed the request, again. But it is the same, as for the previous requests)</p>
<p dir="auto">There are different debug outputs as well, but they are all related to other requests, this error message and stack trace are the first log lines that appear, when performing the request.</p>
<p dir="auto">Best regards,<br />
fbu</p>
<hr />
<p dir="auto"><img src="/assets/uploads/files/smf/0000000004883-nullpointer_stacktrace.png" alt="nullpointer_stacktrace.png" class="img-markdown  img-fluid" width="1685" height="1355" /></p>
]]></description><link>https://forum.netxms.org/post/26791</link><guid isPermaLink="true">https://forum.netxms.org/post/26791</guid><dc:creator><![CDATA[fbu]]></dc:creator><pubDate>Fri, 18 Oct 2019 15:20:57 GMT</pubDate></item><item><title><![CDATA[Reply to POST requests in NetXMS REST API not working ({"error":46}) on Fri, 18 Oct 2019 15:05:47 GMT]]></title><description><![CDATA[<p dir="auto">Also there should be some debug output. If possible attach full log for request.</p>
<p dir="auto">I just tested on my build system and it seems to work. This is Jetty log:</p>
<pre><code>2019-10-18 18:03:01,532 DEBUG | qtp635934462-14 | org.netxms.websvc.handlers.AbstractHandler              | POST: data = {"columns":[{"isRegexp":false,"dciName":"System.CPU.Usage","columnName":"System.CPU.Usage"}],"baseObject":"2"}
2019-10-18 18:03:01,533 DEBUG | qtp635934462-14 | org.netxms.websvc.handlers.AbstractHandler              | session_handle: f5b2061a-92f2-439e-b971-8769e7d85fd0
2019-10-18 18:03:01,533 DEBUG | qtp635934462-14 | org.netxms.websvc.handlers.AbstractHandler              | Handler attached to session f5b2061a-92f2-439e-b971-8769e7d85fd0
2019-10-18 18:03:01,533 DEBUG | qtp635934462-14 | org.netxms.websvc.handlers.AbstractHandler              | POST adhoc summaryTable: baseObject = 2
Oct 18, 2019 6:03:01 PM org.restlet.engine.log.LogFilter afterHandle
INFO: 2019-10-18	18:03:01	127.0.0.1	admin	127.0.0.1	8000	POST	/summaryTable/adHoc	-	200	115	130	12	http://127.0.0.1:8000	Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0	-
</code></pre>
<p dir="auto">and request screenshot attached.</p>
<p dir="auto">Best regards,<br />
Victor</p>
<hr />
<p dir="auto"><img src="/assets/uploads/files/smf/0000000004881-adhoc.png" alt="adhoc.png" class="img-markdown  img-fluid" width="1960" height="1304" /></p>
]]></description><link>https://forum.netxms.org/post/26790</link><guid isPermaLink="true">https://forum.netxms.org/post/26790</guid><dc:creator><![CDATA[victor]]></dc:creator><pubDate>Fri, 18 Oct 2019 15:05:47 GMT</pubDate></item><item><title><![CDATA[Reply to POST requests in NetXMS REST API not working ({"error":46}) on Fri, 18 Oct 2019 14:59:28 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">do you have stack trace below "caused by"? Because this is seems to be root cause.</p>
<p dir="auto">Best regards,<br />
Victor</p>
]]></description><link>https://forum.netxms.org/post/26789</link><guid isPermaLink="true">https://forum.netxms.org/post/26789</guid><dc:creator><![CDATA[victor]]></dc:creator><pubDate>Fri, 18 Oct 2019 14:59:28 GMT</pubDate></item></channel></rss>