Body: <p>I created a postman test with api4 of civicrm. It adds to the body as x-www-form-urlencoded:</p>
  <pre><code>key: params 
  value: {&quot;limit&quot;: 5}
  </code></pre>
  <p>This works fine and returns only 5 results.</p>
  <p>I tried to do the same in javascript with nodejs but the limit is always ignored.</p>
  <pre><code>const response = await axios.post(url.toString(), qs.stringify({ 
                'limit': 5,
              }), {
                headers: {
                  Authorization: `Bearer ${mykey}`,
                  Accept: '*/*',
                  'Content-Type': 'application/x-www-form-urlencoded'
                }, });
  </code></pre>
  <p>Any ideas why this doesn't work?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-01-08T20:02:32.370Z
Comments.Text: How is the `{'limit': 5}` param actually getting form encoded by your code? It looks to simply be a json string?
Comments.UserDisplayName: Coleman
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-01-08T20:44:36.467Z
Comments.Text: Actually qs (querystring) should create it. However, I also tried different approaches 
  e.g. 
  const params = new URLSearchParams();
  params.append('params[0][limit]', '5');
  or converting it manually. But nothing worked.
Comments.UserDisplayName: Gesko
Tags: <api><javascript>
Title: civi api response limit working in postman but not in javascript
ThreadText: # civi api response limit working in postman but not in javascript
  
  (Asked by: username_0 on 2024-01-08)
  
  I created a postman test with api4 of civicrm. It adds to the body as x-www-form-urlencoded:
  key: params 
  value: {"limit": 5}
  
  This works fine and returns only 5 results.
  I tried to do the same in javascript with nodejs but the limit is always ignored.
  const response = await axios.post(url.toString(), qs.stringify({ 
                'limit': 5,
              }), {
                headers: {
                  Authorization: `Bearer ${mykey}`,
                  Accept: '*/*',
                  'Content-Type': 'application/x-www-form-urlencoded'
                }, });
  
  Any ideas why this doesn't work?
  
  **Tags:** api, javascript
  
  > **Comments:**
  > **username_1**: How is the `{'limit': 5}` param actually getting form encoded by your code? It looks to simply be a json string?  
  > **username_0**: Actually qs (querystring) should create it. However, I also tried different approaches  e.g.  const params = new URLSearchParams(); params.append('params[0][limit]', '5'); or converting it manually. But nothing worked.  
  
  ---
  
  ## 0 answers
  
  