-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
| '__metadata': { 'type': `SP.Data.${listTitle}ListItem` }, |
Hi,
I'm using this module, and he is amazing, but in my tests i'm getting Response Code 400 when create a new item in list....
After some hours and thousands of Chrome tabs in Stackoverflow, i did not find any reference about possible incorrect _metadata type format.
Then, i test parsing _metadata like this:
body: { "__metadata": { "type": "SP.List" }, "Title": "New Item" },
And error 400 no more occours....
If you wan't to try or put this in your documentation can be very helpfull for income users.
Here's my full code for consultant:
const spClient = sprequest.create({
username,
password
})
spClient.requestDigest(url).then(digest => {
return spClient.post(`${url}/_api/web/lists/getByTitle('nodejsapp')/items `, {
body: {
"__metadata": {
"type": "SP.List"
},
"Title": "New Item"
},
headers: {
'X-RequestDigest': digest
}
})
}).then(function () {
console.log('item just created!!!');
}, function (err) {
// if (err.message.indexOf('-2130575342') === -1) {
// console.log('Hmmmmm something went wrong');
// console.log(err);
// return;
// }
// console.log('list already exists!!!');
})
.catch(function (err) {
console.log('Hmmmmm something went wrong');
console.log(err);
});
Metadata
Metadata
Assignees
Labels
No labels