3

I am using on premise SharePoint server 2016.I am using rest api to update a list.I have a list having space in it's name so while passing this name it causes problem.Is it possible to pass file name having space to update operation. Suppose list name is 'abc list'.

 $.ajax  
    ({  
        url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/GetByTitle('abc%20list')/items("+Idtoupdate+")", // list item ID  
        type: "POST",  
        data: JSON.stringify  
        ({  
            __metadata:  
            {  
                type: "SP.Data.abc%20list"  
            },  
            Uploaded:value

        }),  
        headers:  
        {  
            "Accept": "application/json;odata=verbose",  
            "Content-Type": "application/json;odata=verbose",  
            "X-RequestDigest": $("#__REQUESTDIGEST").val(),  
            "IF-MATCH": "*",  
            "X-HTTP-Method": "MERGE"  
        },  
async: false,  
        success: function(data, status, xhr)  
        {  
            debugger;
        },  
        error: function(xhr, status, error)  
        {  
            debugger;
        }  
    });

I am getting error at json.strignify.

Error:

{"readyState":4,"responseText":"{\"error\":{\"code\":\"-1, Microsoft.SharePoint.Client.InvalidClientQueryException\",\"message\":{\"lang\":\"en-US\",\"value\":\"A type named 'SP.Data.Approver DashboardListItem' could not be resolved by the model. When a model is available, each type name must resolve to a valid type.\"}}}","responseJSON":{"error":{"code":"-1, Microsoft.SharePoint.Client.InvalidClientQueryException","message":{"lang":"en-US","value":"A type named 'SP.Data.Approver DashboardListItem' could not be resolved by the model. When a model is available, each type name must resolve to a valid type."}}},"status":400,"statusText":"Bad Request"}

  • Can you please post the error you are getting? – Ganesh Sanap Aug 1 at 7:35
  • posted an error – user85213 Aug 1 at 7:43
  • This is the same problem as I mentioned in my answer. Hit this URL in browser : /_api/web/lists/GetByTitle('listName')/ListItemEntityTypeFullName to check the ListItemEntityTypeFullName for your list. – Ganesh Sanap Aug 1 at 7:48
5

You can pass the display name of your SharePoint List in REST API call like below:

_spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/GetByTitle('abc list')/items"

Also make sure you are passing correct ListItemEntityTypeFullName in type property inside __metadata.

You can check ListItemEntityTypeFullName of your list using below URL:

/_api/web/lists/GetByTitle('listName')/ListItemEntityTypeFullName

Commone Format of ListItemEntityTypeFullName:

SP.Data.ListNameListItem

Replace only ListName with your list name.

Update:

For your case try using below:

data: JSON.stringify  
    ({  
        __metadata:  
        {  
            type: "SP.Data.Approver_x0020_DashboardListItem"  
        },  
        Uploaded:value

    })

Generally in ListItemEntityTypeFullName, Space is replaced by _x0020_. But, it is always recommended to check ListItemEntityTypeFullName of your list by using:

/_api/web/lists/GetByTitle('listName')/ListItemEntityTypeFullName
  • Resoved by getting ListItemEntityTypeFullName using /_api/web/lists/GetByTitle('listName')/ListItemEntityTypeFullName – user85213 Aug 1 at 7:55
  • Great. please upvote(^) and accept it as an answer as it helped you. – Ganesh Sanap Aug 1 at 7:56

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.