REST addViewField "Cannot handle the data at position 0."

SharePoint Asked by Ben Short on December 2, 2021

I’m currently writing an initialisation script for a SharePoint-hosted application which checks if a list (used for launcher items) exists. If it doesn’t, then it runs through a series of processes to create the list, add fields and then update the view.

Here’s a snippet of code which loops through the payload objects and creates a new field and adds said field to the view for each object. This script utilises AngularJS and ShareCoffee.

var payload = [{
    'Title': 'Icon URL',
    'FieldTypeKind': 11,
    'Required': true
    'Title': 'Destination URL',
    'FieldTypeKind': 11,
    'Required': true

angular.forEach(payload, function (value, key) {
    $http({ url: 'web/lists/getByTitle('Launcher%20Items')/Fields', payload: payload[key], hostWebUrl: hostweburl }))
    .success(function (data) {
        console.log('Created field with the title ' + payload[key].Title);
        // field created, add to view
        $http({ url: 'web/lists/getByTitle('Launcher%20Items')/views/getByTitle('All%20Items')/viewFields/addViewField('' + payload[key].Title + '')', hostWebUrl: hostweburl }))
        .success(function (data) {
            console.log('Added element to view');
        .error(function (data, status) {
    .error(function (data, status) {

This code should work fine, but when it runs I get an Error 400 response from SharePoint with the error code

1, Microsoft.SharePoint.Client.InvalidClientQueryException

As well as a message saying

value: “Cannot handle the data at position 0.”

Is there any reason why this would happen or what this means? Google doesn’t seem to bring much back.

One Answer

The issues appears to be that rather than 'creating' a new record within the viewField, you instead 'update' the existing record.

Replacing the class with seems to resolve the issue.

Answered by Ben Short on December 2, 2021

Add your own answers!

Related Questions

Sharepoint 2013 Query Filter Using POST

1  Asked on November 11, 2021 by ciprian


Adding “request change” button to Sharepoint Task

1  Asked on November 11, 2021 by ricardo-rodrigues


Create external users using CSOM

3  Asked on November 8, 2021 by marlou


Import Excel to SharePoint List Tutorial Error

1  Asked on November 5, 2021 by seaandtea


Ask a Question

Get help from others!

© 2023 All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP