1

Creating and updating list items via jQuery/REST. The script has been functional for roughly four months now, but this morning decided to start throwing an error.

error: {code: "-2147024809, System.ArgumentException",…} code: "-2147024809, System.ArgumentException" message: {lang: "en-US", value: "Value does not fall within the expected range."} lang: "en-US" value: "Value does not fall within the expected range."

Google feeds me information on this error in regards to working with files, and the pathway not being specified properly, but I can't seem to figure out why this would have ceased functioning. I've verified the access method for both GET and DELETE actions, but creating new records and updating existing ones throws the same error.

Create snippet below:

$.ajax({
  url: _spPageContextInfo.webAbsoluteUrl + "/_api/Web/Lists/GetByTitle('List Name')/items",
  type: "POST",
  contentType: "application/json;odata=verbose",
  data: JSON.stringify(item),
  async: false,
  headers: {
    "Accept": "application/json;odata=verbose",
    "X-RequestDigest": $("#__REQUESTDIGEST").val(),
  },
  success: function (data,textStatus, jqXHR) {
    ...do stuff...
  },
  error: function (jqXHR,textStatus,errorThrown) {
    ...make noise...
  }
});

I've validated the item's data in the error function, and that _spPageContextInfo.webAbsoluteUrl is properly evaluating to the desired URL. The list is larger, but the operations were functional above the 5000 item limit until today.

Thanks in advance for any assistance.

EDIT: Just tried to apply updates directly to the list and the error is coming up from the datasheet view without highlighting any offending columns. So it's not a script error, but something in the list itself causing the problem.

2

This error is usually thrown when the value being set for a column doesn't conform to its type and limits. For example, you might be updating a Number column with a string value or a value that exceeds the SharePoint number column limit.

This issue might occur when you are creating/updating listitem having Number, Choice, Lookup, People, DateTime columns. I'd debug in browser and see what values I'm passing to each of such columns.

  • That was my first check. The update in particular is only posting changes to two fields, both of which are single line of text types and receiving a string as input in the payload. – Joe Feb 17 '16 at 15:44
2

The path of the Document Library/ List name seems be wrong. or can you try to give the path using below snippet

sp.appcontextsite is the right way of referrring the library/list

 var fileCollectionEndpoint = String.format(
            "{0}/_api/sp.appcontextsite(@target)/web/getfolderbyserverrelativeurl('{1}')/files" +
            "/add(overwrite=true, url='{2}')?@target='{3}'",
            appWebUrl, serverRelativeUrlToFolder, fileName, hostWebUrl);

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.