JSON sending error occurs if the data exceeds the maximum length limit when communicating with the Web

I'm encountering an issue while trying to send a JSON object to a .NET Web API. I have a multidimensional array that I convert into JSON and then send to the web service. The total length of the object exceeds 50,000 characters. However, if I slice the array, everything works fine. It seems that as long as the payload is under 2500 characters, it goes through without any problems.

   let value = JSON.stringify(this.excelData.results.slice(2, 2));
   axios({
   method: 'post',      
   url: 'http://adminapiSystem.com/api/saveJSONData',
   params: {          
     value: value
    }    
   })
  .then((res) => {
    console.log('Saved')
  }) 
  .catch(err => {
      console.log(err)
  
  } )

Initially, I thought the maximum allowed length was 2097152 or 4MB.

Here's the function in my web service:

     Public Function PostValue(ByVal value As String) As String
        Dim ret As String = SendDataSQL(value)
        Return ret
    End Function

The encountered error message reads:

        xhr.js?b50d:177 POST http://xxxxx/api/saveJSONData?value=    [insert lengthy encoded JSON data here] 404 (Not Found)
dispatchXhrRequest @ xhr.js?b50d:177
... // additional error handling details

In my web config, I have specified:

       <scripting>
  <webServices>
    <jsonSerialization maxJsonLength="2147483644" />
  </webServices>
     </scripting>

And in the system settings:

  <system.web>
  <compilation debug="true" targetFramework="4.6.1" />
<httpRuntime targetFramework="4.6.1" maxUrlLength="10240" relaxedUrlToFileSystemMapping="true" />
<customErrors mode="Off" />
 </system.web>

Lastly, I am using HostBuddy as my hosting service provider.

Answer №1

When sending a POST request, it's important to note that the data should not be included in the URL.

The maximum length for a GET request is 2,048 characters, exceeding this limit will result in an HTTP error.

To overcome this limitation, you can use the POST method and include the data in the request BODY, which does not have any specific limits.

If you're using Axios, the following code snippet can help you achieve this:

axios({
  method: 'post',
  url: 'http://adminapiSystem.com/api/saveJSONData',
  data: {
    value: value
  }
});

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Monitor for the specific parameter in the incoming GET request

My application is using the POST method to submit jobs remotely. After submitting a job, I receive a unique job ID from the POST request that allows me to check the status of the job using a GET request. $http.get('http://localhost:8090/jobs/'+i ...

Issue with rendering JSON in Backbone.js -

I am facing a coding challenge: window.TicketCollection = Backbone.Collection.extend({ model:Tickets, url:"/index.php/tickets/viewJSON" }); window.TicketsView = Backbone.View.extend({ tagName:'div', initialize: function () { ...

Leveraging jquery's setInterval for automating tasks like a cronjob

I've been experimenting with Cronjobs and I've run into a roadblock. My goal is to have the cronjob execute every X minutes, containing a script with JavaScript that calls an ajax request every second for the next 60 seconds. The ajax call trigge ...

refresh Laravel 5.1 webpage content seamlessly without page reloading

Is there a way to update page content in Laravel 5.1 every second without reloading the page for all users? Here is my current view: I'm trying to refresh data without reloading the page using a foreach loop, but I'm not sure how to accomplish ...

Guide on Sending an ExpandoObject as a Response in Web API

So I have this action described below: public class BookController : ApiController { // GET api/book/5 public object Get(int id) { using (System.Data.Common.DbDataReader reader = this.ExecuteReader("SELECT BookId, BookName FROM Book WH ...

Flexbox causing issues with relative positioning at the bottom of the screen in various browsers

My flex component looks like this: <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" ... width="100%" height="100%" creationComplete="init()"> ....... <components:Naviga ...

Highcharts JS encountered an error: x[(intermediate value)(intermediate value)(intermediate value)] is not a valid constructor

I'm in the process of creating a bar chart by fetching options from an ajax response. However, I encountered an error when passing the object to the highcharts constructor. Uncaught TypeError: x[(intermediate value)(intermediate value)(intermediate v ...

Tips for capturing the Three.js model file content and assigning it to a variable

After exporting a model from Blender to Three.js, the resulting file contains JSON data. There are two methods I know of for loading this model: var loader = new THREE.JSONLoader() var material = new THREE.MeshPhongMaterial({color: '#8080a0'}) ...

Various relationships in Sails.js

Exploring associations in Sails.js beta (version 0.10.0-rc4) has been quite intriguing for me. My current challenge involves linking multiple databases to produce a unified result (utilizing sails-mysql). The association scheme I'm working with invo ...

Error: Query has already been processed: Updating Todo with ID "612df063a8f"

After updating mongoose to the latest version (6.0.2), I encountered an error that crashes the application whenever .updateOne() is executed. However, the object is still updated inside the database. Below is my code snippet: async(req,res) => { a ...

Issues with jqGrid treeGrid expanding and collapsing functionality not functioning as expected

I'm having some trouble setting up a treeGrid using jqGrid 4.2.1. After working on it, the visual aspect looks fine, but I'm encountering an issue with expanding and collapsing nodes. The icon toggles properly, but the groups remain visible. Her ...

Creating a query string using a jQuery array that contains multiple values for a query variable

After writing some code to convert an array into a filter string, I noticed that the generated string was not in the format I wanted. product_size=123&product_size=456 Instead of this, I needed it to be product_size=123+456. To achieve this, I reali ...

Convert a CSV file into JSON format using RxJava2

[UPDATED] Greetings I am faced with the task of converting the data from a CSV file into JSON format based on a Java class, using RxJava2. To illustrate, here is an example of how the CSV file is structured: 1,John,Smith The Java class called User has ...

Creating nodes using JSON selector is a straightforward process that involves identifying the specific

I have JSON data containing information about various papers and their publication venues, presented in the following format: {"id": "1", "title": "Paper1", "venue": {"raw": "Journal of Cell Biology"}} {"id": "2", "title": "Paper2", "venue": {"raw": "Natu ...

Is there a way to utilize localStorage to retain a classlist toggle status for a light/dark mode theme switch on the browser?

I am currently working on a portfolio website that features a light/dark mode theme switch. The functionality of the switch is working properly, but it doesn't save the user's preference when they refresh the page or navigate to another section. ...

Creating a schema for a JSON element in KendoUI: A simple guide

Looking for assistance on writing the schema for a JSON object with specific structure. { sev: [{ t: "t1", v: v1 }, { t: "t2", v: v2 }], sum: [{ te: "te1", ve: ve1 }, { te: "te2", ...

JQuery: Issue with closing modal on certain popups

I have configured a popup that is associated with 6 different products. While it functions correctly for the first product, it does not seem to work properly for the rest. <script> //var modal = document.getElementById("m ...

The absence of the object's shadow is conspicuously noticeable - three.js

View Screenshot Hey there! I recently exported a 3D model tree from Blender and everything seemed to have gone smoothly, but I encountered an issue. The shadow appears on the trunk and branches, however, it is not reflecting properly. Could this be due to ...

Sending an array through an AJAX request to a Java class using Struts2

Issue with Javascript-AJAX Call function assignTask(){ var formdata = "xyz"; var taskList = []; $.each($("input[name='taskname']:checked"), function(){ taskList.push($(this).val()); }); $.ajax({ type: "post", data: {taskList:taskList ...

Refresh the page to verify if the user has successfully established a connection with PhoneGap through AngularJS

I am currently developing an app using PhoneGap. I have successfully implemented a feature to check if the user is connected to the internet or not. However, if the user is not connected, I would like to provide a button for them to click on in order to re ...