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.