I am trying to upload via my webpart new items to SP list.
Almost everything works fine, but I am not able to upload attachments, on save action I am getting this error -
[Error: Error making HttpClient request in queryable [400] ::> {"error":{"code":"-1, Microsoft.SharePoint.Client.InvalidClientQueryException","message":{"lang":"en-US","value":"An unexpected 'StartObject' node was found when reading from the JSON reader. A 'PrimitiveValue' node was expected."}}}]
Bellow is my piece of code (just pieces from attachment function and render. Upload is working already with textfields, datetime etc...
const [file, setFile] = useState<File>();
const handleFileChange = (e: ChangeEvent<HTMLInputElement>) => {
if (e.target.files){
setFile(e.target.files[0]);
}
};
const handleUploadClick = () => {
if(!file){
return;
}
console.log(file);
};
let propertiesSave = {};
propertiesSave = {
Attachments: file !== undefined ? file : undefined
}
return (
<div>
<input type="file" onChange={handleFileChange} />
<div>{file && \${file.name} - ${file.type}`}</div><button onClick={handleUploadClick}>NahraƄ</button></div>`
)
In console.log(file) I can get every information about file, which is uploaded, so thats works, but I thing the problem is with save action (maybe I am missing something)