1
votes

I've got a REST API that uses Azure API Management, and when testing with large query strings, noticed that once the URL exceeds something around 1800 characters, the APIM does not route the request & instead sends back an error saying "Resource not found" & a status code of 400. When I run the same request directly to my REST endpoint locally, it works fine (I've increased the Kestrel server max request length like so in my Program.cs file :

WebHost.CreateDefaultBuilder(args)
                .ConfigureKestrel((context, options) =>
                {
                    options.Limits.MaxRequestLineSize = 2147483647;
                    options.Limits.MaxRequestBufferSize = 2147483647;
                })
                .UseStartup<Startup>();

Is there a similar configuration I can do for azure APIM to increase the max URL size allowed?

2

2 Answers

1
votes

So answering my own question :

Got through to Microsoft Support and they acknowledged that this was a limitation with the consumption tier for APIM. One workaround for this was to switch to different tier. I have copied over the response I got from azure support below :

Root Cause:

For the previous investigation, this ticket is about the consumption tier url limitation.

  1. As this configuration for the max URL length cannot be changed from the APIM policies. At this moment, the consumption tier have this limitation from our backend setting which is already written into the main configuration.

  2. The consumption tier's url limit is like below. max url length: 4096 max query string length: 2048

The space will be changed as %20 which is 3 characters.

  1. The developer, basic and premium tier of APIM use the same backend structure and the restriction will not exist in this tiers different from the consumption tier. These tiers will have over 10K url length.
0
votes

If you are using the GET method, you are limited to a maximum of 2,048 characters, minus the number of characters in the actual path, So i would suggest you to check the path length and your URL length. The Maximum length of URL is limited by the different browsers.

You can check this thread explaining the length issues for URL for different browser:

What is the maximum length of a URL in different browsers?

All file systems supported by Windows use the concept of files and directories to access data stored on a disk or device. Windows developers working with the Windows APIs for file and device I/O should understand the various rules, conventions, and limitations of names for files and directories.

You can read through below doc to understand the path length restriction for a server in the below doc:

https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file?redirectedfrom=MSDN#maxpath

Additionally , here is a similar discussion for the URL query string length while consuming APIM, please check if it helps, as per the conclusion " length issue will be there when any one part of the path is longer than 261 characters" suggested by @MisterHux:

Do Azure API Mgmt have a length limit on path/parameters?

Hope it helps.