2

I am getting the following error when I try to change role assignments for a file. I can tell from the error that it exceeds the MaxUrlLength value but where do I change this value?

Code

401

Body

The length of the URL for this request exceeds the configured maxUrlLength value.

Also, shouldn't this be a 400 status code?

Much appreciated!

My Sample URL

https://TENANTNAME-my.sharepoint.com/personal/user_random_com/_api/web/GetFileByServerRelativeUrl('/personal/user_random_com/Documents/Hello.txt')/ListItemAllFields/roleassignments/addroleassignment(principalid=5,roledefid=******)
2

There is no way to edit the maxUrlLength for Sharepoint Online as this is a value in the web.config which you don't have access to.

To answer your question: No, you can't change the maxUrlLength configuration.

Possible steps to take:

  • See if you can include data in the request body, like this.
  • Use the GetFileById route, like this.

As for the error code, I believe you're right - as 401 means unauthorized. 400 would be more suitable as that means bad request.

1

If you find that your URL length is too long, you can try to use parameters instead:

Eg.

Original url:

https://TENANTNAME-my.sharepoint.com/personal/user_random_com/_api/web/GetFileByServerRelativeUrl('/personal/user_random_com/Documents/Hello.txt')/ListItemAllFields/roleassignments/addroleassignment(principalid=5,roledefid=******)

Parameter URL:

https://TENANTNAME-my.sharepoint.com/personal/user_random_com/_api/web/GetFileByServerRelativeUrl(@FileLoc)/ListItemAllFields/roleassignments/addroleassignment(principalid=5,roledefid=******)?@FileLoc='/personal/user_random_com/Documents/Hello.txt'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.