We are trying to post a really long query string, that exceeds 2048 characters to sharepoint REST API. I am making a post to the below API


We modified the config file of our SharePoint site to the below,

   <httpRuntime maxQueryStringLength="65536"/>

    <requestLimits maxQueryString="65536" />

But still SharePoint throws a 400 error stating that the maxquery length is exceeded. Do I have to change the configurations in some other place?

Is it possible to send the query string as part of the http post body so that the query string length could be let alone ?

  • What are you trying to post? Can you share the full URL? – Akhoy Oct 2 '15 at 3:30
  • I am trying to retrieve a lot of groups. The url contains a lot of $Filter parameters - example - http: //sitename/_api/web/sitegroups?$select=LoginName,Id,Title&$Filter=LoginName%20eq%20'Test_Grp'or%20LoginName%20eq%20'BUADELCI'%20or%20LoginName%20eq%20'BUCENTMKT'%20or%20LoginName%20eq%20'BUADHIIP'%20or%20LoginName%20eq%20'BUAHRWIP'%20or%20LoginName%20eq%20'BUADLPLA'%20or%20LoginName%20eq%20'BUALEXAN'%20or%20LoginName%20eq%20'BUBERRBA'%20or%20LoginName%20eq%20'BUCAMPBE'%20or%20LoginName%20eq%20'BUMNLGRN'%20or%20LoginName%20eq%20'BUBURNIP'%20or%20LoginName%20eq%20'BUCHARIP' – jkr Oct 2 '15 at 3:34

To avoid this, use CAML query and post it in the request body. Use a CAML query builder to build the query. This doesn't have restrictions on the length. This might become long and repetitive. But AFAIK, there is no other way to post huge request bodies in the request URL.

CAML query:

        <FieldRef Name='Title' />
        <Value Type='Text'>Group 1</Value>
        <FieldRef Name='Title' />
        <Value Type='Text'>Group 2</Value>

Sample in JS:

function getDataWithCaml(siteurl, caml) {
var endpoint = siteurl+"/_api/Web/SiteUserInfoList/getitems";
var requestData = { "query" :
      {"type": "SP.CamlQuery" }
      , "ViewXml": caml
return $.ajax({
url: endpoint,
method: "POST",
data: JSON.stringify(requestData),
headers: {
    "X-RequestDigest": $("#__REQUESTDIGEST").val(),
    "Accept": "application/json; odata=verbose",
    "Content-Type": "application/json; odata=verbose"


var caml = "<View><Query>"+
     "<FieldRef Name='LinkTitle' />"+
     "<Value Type='Computed'>GroupName</Value>"+
getDataWithCaml("http://siteurl", caml).done(function(data)
var resultSet= data.d.results;  
var title = [];
var id=[];
for(var i=0;i<resultSet.length;i++){
  • Any way of not having to use CAML? – Christoph Bühler May 8 '18 at 12:58
  • What is it that you're trying to do? – Akhoy May 8 '18 at 14:52

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.