SharePoint 2016 Logo

Once I tried to make the application to migrate a custom data source from SharePoint 2010 to SharePoint 2019 on-premise. To make it easier, I decided to make to separate solutions – the first one to export the data from SharePoint 2010 from the list to JSON and attachments to local folder(CSOM for SharePoint 2010 sucks) and the utility to import data to SharePoint 2019 via REST.

I know how to achieve access token for authorization and how to use it. But I don’t understand why the manual how to make add-insert requests can be so poor. In spite of the fact that the there are many tutorials and examples, none of them has the information about one step which follows to the error "Bad Request 400" on execution.

Approximately 5 hours I could see only this error on execution.

The problem was in 1 byte, 1 char.

So, the information which should be added to the new list item looks like this:

   var itemPayload = new
          __metadata = new { type = "SP.Data.TestListItem" },
          Title = "Test string value"

where  "SP.Data." – const, "Test" – the title of the list, "ListItem" means you create a List Item.

In my case the list was called in only lower case ‘test’ and I used it as it is:

          __metadata = new { type = "SP.Data.testListItem" },

But! It was an error and when I modified the char ‘t’ to ‘T’ everything started to work successfully.