<?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[[SOLVED] Error making API call in support script with Axios: big headers]]></title><description><![CDATA[<p>Hello,<br />
I'm experimenting with calling an external API from a script.<br />
I have two APIs on a local server: one can be called from JSReport, the other throws a cryptic error.</p>
<pre><code>const axios = require('axios'); 
 
async function callApi() {
    return axios.get('http://localhost:8800/api/PING.PING?noblock');
}
 // add jsreport hook which modifies the report input data
async function beforeRender(req, res) {
    const r = await callApi();
    console.log(&quot;ret is &quot;,r.data)
    req.data = { ...req.data, ...r.data}
}
</code></pre>
<p>while if I change it to a login API with post method:</p>
<pre><code>const axios = require('axios'); 
 
async function callApi() { 
    return axios.post('http://localhost:8800/api/REST_ACCOUNT.LOGIN',{
          Usercode:&quot;000000&quot;,
          Codice_Concessione:&quot;GG&quot;,
          Browser:&quot;Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36&quot;,
           Password:&quot;xxxxxxxxxx&quot;,
           Lingua:&quot;POR&quot;
         }
    ); 
}
</code></pre>
<p>i get this error</p>
<pre><code>2020-09-30T14:35:07.392Z - debug: Executing script prova-script.js using http-server strategy
2020-09-30T14:35:09.941Z - warn: Rendering request 1 finished with error in 2554 ms
2020-09-30T14:35:09.941Z - warn: Error when processing render request 1 Parse Error Error: Parse Error
    at Socket.socketOnData (_http_client.js:442:20)
    at Socket.emit (events.js:198:13)
    at Socket.EventEmitter.emit (domain.js:466:23)
    at addChunk (_stream_readable.js:288:12)
    at readableAddChunk (_stream_readable.js:269:11)
    at Socket.Readable.push (_stream_readable.js:224:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:94:17)
2020-09-30T14:35:09.942Z - warn: Error during processing request at h
</code></pre>
<p>I've tested calling the latter API  on a browser page with the same Axios code and the params are correct.<br />
The only unusual things in this API are:</p>
<ul>
<li>return data is a 9K json</li>
<li>response headers are pretty big, around 12K because of the JWT token</li>
</ul>
<p>Any ideas?<br />
Thanks</p>
]]></description><link>https://forum.jsreport.net/topic/1741/solved-error-making-api-call-in-support-script-with-axios-big-headers</link><generator>RSS for Node</generator><lastBuildDate>Thu, 10 Sep 2026 11:02:00 GMT</lastBuildDate><atom:link href="https://forum.jsreport.net/topic/1741.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 30 Sep 2020 14:47:39 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [SOLVED] Error making API call in support script with Axios: big headers on Wed, 30 Sep 2020 16:08:40 GMT]]></title><description><![CDATA[<p>Hello,<br />
I'm experimenting with calling an external API from a script.<br />
I have two APIs on a local server: one can be called from JSReport, the other throws a cryptic error.</p>
<pre><code>const axios = require('axios'); 
 
async function callApi() {
    return axios.get('http://localhost:8800/api/PING.PING?noblock');
}
 // add jsreport hook which modifies the report input data
async function beforeRender(req, res) {
    const r = await callApi();
    console.log(&quot;ret is &quot;,r.data)
    req.data = { ...req.data, ...r.data}
}
</code></pre>
<p>while if I change it to a login API with post method:</p>
<pre><code>const axios = require('axios'); 
 
async function callApi() { 
    return axios.post('http://localhost:8800/api/REST_ACCOUNT.LOGIN',{
          Usercode:&quot;000000&quot;,
          Codice_Concessione:&quot;GG&quot;,
          Browser:&quot;Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36&quot;,
           Password:&quot;xxxxxxxxxx&quot;,
           Lingua:&quot;POR&quot;
         }
    ); 
}
</code></pre>
<p>i get this error</p>
<pre><code>2020-09-30T14:35:07.392Z - debug: Executing script prova-script.js using http-server strategy
2020-09-30T14:35:09.941Z - warn: Rendering request 1 finished with error in 2554 ms
2020-09-30T14:35:09.941Z - warn: Error when processing render request 1 Parse Error Error: Parse Error
    at Socket.socketOnData (_http_client.js:442:20)
    at Socket.emit (events.js:198:13)
    at Socket.EventEmitter.emit (domain.js:466:23)
    at addChunk (_stream_readable.js:288:12)
    at readableAddChunk (_stream_readable.js:269:11)
    at Socket.Readable.push (_stream_readable.js:224:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:94:17)
2020-09-30T14:35:09.942Z - warn: Error during processing request at h
</code></pre>
<p>I've tested calling the latter API  on a browser page with the same Axios code and the params are correct.<br />
The only unusual things in this API are:</p>
<ul>
<li>return data is a 9K json</li>
<li>response headers are pretty big, around 12K because of the JWT token</li>
</ul>
<p>Any ideas?<br />
Thanks</p>
]]></description><link>https://forum.jsreport.net/post/7788</link><guid isPermaLink="true">https://forum.jsreport.net/post/7788</guid><dc:creator><![CDATA[zontarian]]></dc:creator><pubDate>Wed, 30 Sep 2020 16:08:40 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED] Error making API call in support script with Axios: big headers on Invalid Date]]></title><description><![CDATA[<p>Ok, as I suspected the problem was with the huge headers.<br />
Since the same problem was in Postman, we solved it with the same workaround:</p>
<pre><code>NODE_OPTIONS=--max-http-header-size=16384 jsreport start
</code></pre>
<p>this is the original post [<a href="https://github.com/postmanlabs/postman-app-support/issues/8656" rel="nofollow">https://github.com/postmanlabs/postman-app-support/issues/8656</a>]</p>
]]></description><link>https://forum.jsreport.net/post/7790</link><guid isPermaLink="true">https://forum.jsreport.net/post/7790</guid><dc:creator><![CDATA[zontarian]]></dc:creator><pubDate>Invalid Date</pubDate></item></channel></rss>