Request maxUrlLength and URL parameters
Via a Power Automate flow you can interact with the SharePoint REST API via a Send an HTTP request action. Sometimes you can run into the maxUrlLength limit with this approach. This blog shows how you can avoid this limit by using URL parameters.
Inspiration
This question from jleystral:
We have a library and request a comment field when manually triggering the file. This is inserted into the version comment of the file via HTTP request with Power Automate. Now we have an error with a comment that is about 600 characters long. The following message came up in Power Automate “The length of the URL for this request exceeds the configured maxUrlLength value.” Is there a way to increase the maxUrlLength?
Power Users Community thread: The length of the URL for this request exceeds the configured maxUrlLength value. How to increase the maxUrlLength Value.
Short answer
No. That was the short answer to this question 😉
The maxUrlLength is a web.config settings of the servers running these services. This is managed by Microsoft and (as far as I am aware) there is not a setting in either the user interface or via command line to increase the limit.
URL Parameters
However, looking at the original HTTP request of the user I thought there probably was a way to shorten the URL and avoid the limit.
The GetFileByServerRelativeUrl and the CheckIn comment values were pretty long. Luckily I found a post about URL parameters from AJ on StackExchange.
Seems that URL parameters are not counted in the limit! 🙂
In this case I would use URL parameters for the GetFileByServerRelativeUrl and the CheckIn comment. Just replace the values in the GetFileByServerRelativeUrl and CheckIn methods by @v & @w parameters and add those at the end of your URI value.
Flow setup
In this example we are using the CheckIn of document as an example. However, the URL parameter approach can also be used in other type of methods as well.
1. Add a Manually trigger a flow action.
2. Add a Initialize variable action (optional).
a. Provide a Name, I used vUrlparameter
b. Select String as type
c. Provide a value. I used a long path like /sites/Prozesslandschaft/Shared%20Documents/Ordnerpfad/20220806/Document.docx
3. Add a second Initialize variable action (optional).
a. Provide a Name, I used Comment
b. Select String as type
c. Provide a value. I used a random string of at least 600 characters
4. Add a Send an HTTP request to SharePoint action.
a. Select your preferred site in the Site Address
b. Use the POST method
c. Use the URI from the code snippet below
That is it for the setup of this example.
Testing the workaround
When you test the workaround the Send an HTTP request action should succeed without the maxUrlLength exceeded error.
And you should be able to see the comment in the version history as well.
Happy testing!