Api result max size

Product: PowerShell Universal
Version: 1.4.18

Hi, I have Powershell Universal running on IIS 10. There is an api on it that returns a large amount of data.

When querying it I get a 500 (using Invoke-WebRequest):

Invoke-WebRequest : The remote server returned an error: (500) Internal Server Error.

There are no errors in the Powershell Universal logs:

Tue, 07 Nov 2023 12:40:15 GMT	Information	GET /e4api/test 10.90.82.67 EXECUTOR2024

As I understand, the problem is the size of the result. If it is larger than 4 mb I get 500. If it is smaller, everything works. Can you tell me how to get around this limitation?

Upd: the problem does not depend on the request method, I have tried get, put, etc. Only result size.

You’re likely hitting the IIS request size limit.

Thanks for the quick response. Am I correct that these parameters should be added into web.config, which is located in the root of the folder?

My web.config now:

<?xml version="1.0" encoding="utf-8"?>
<configuration>

    <system.web>
        <httpRuntime maxRequestLength="102400" />
    </system.web>

    <system.webServer>
        <handlers>
            <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
        </handlers>
        <aspNetCore processPath=".\Universal.Server.exe" arguments="" forwardWindowsAuthToken="false" stdoutLogEnabled="true" stdoutLogFile=".\logs\log" hostingModel="InProcess" />
        <security>
            <requestFiltering>
                <requestLimits maxAllowedContentLength="104857600" />
            </requestFiltering>
        </security>
    </system.webServer>
</configuration>
<!--ProjectGuid: 588ACF2E-9AE5-4DF1-BC42-BCE16A4C4EDE-->

I rebooted the whole server, but nothing changed.

Add max values:

<?xml version="1.0" encoding="utf-8"?>
<configuration>

    <system.web>
        <httpRuntime maxRequestLength="2147483647" />
    </system.web>

    <system.webServer>
        <handlers>
            <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
        </handlers>
        <aspNetCore processPath=".\Universal.Server.exe" arguments="" forwardWindowsAuthToken="false" stdoutLogEnabled="true" stdoutLogFile=".\logs\log" hostingModel="InProcess" />
        <security>
            <requestFiltering>
                <requestLimits maxAllowedContentLength="4294967295" />
            </requestFiltering>
        </security>
    </system.webServer>
</configuration>
<!--ProjectGuid: 588ACF2E-9AE5-4DF1-BC42-BCE16A4C4EDE-->

Nothing change.
I think I’m doing something wrong =(

Can you check the IIS logs to see if there is any indication there?

Your configuration looks find to me.

Sussess request (result lt 4mb):

2023-11-07 14:29:30 10.90.52.167 GET /e4api/test - 443 - 10.90.82.67 Mozilla/5.0+(Windows+NT;+Windows+NT+10.0;+ru-RU)+WindowsPowerShell/5.1.20348.2031 - 401 2 5 1
2023-11-07 14:29:40 10.90.52.167 GET /e4api/test - 443 KL\chernyshev 10.90.82.67 Mozilla/5.0+(Windows+NT;+Windows+NT+10.0;+ru-RU)+WindowsPowerShell/5.1.20348.2031 - 200 0 0 9943

Failed request (result gt 4mb):

2023-11-07 14:35:21 10.90.52.167 GET /e4api/test - 443 KL\chernyshev 10.90.82.67 Mozilla/5.0+(Windows+NT;+Windows+NT+10.0;+ru-RU)+WindowsPowerShell/5.1.20348.2031 - 500 0 0 11318

or

2023-11-07 14:37:15 10.90.52.167 GET /e4api/test - 443 KL\chernyshev 10.90.82.67 Mozilla/5.0+(Windows+NT;+Windows+NT+10.0;+ru-RU)+WindowsPowerShell/5.1.20348.2031 - 500 0 0 9318

Fixed in version 4.2.11
Tested and confirmed