Hello Developers,
I am unable upload a file(s) (with attachment object) from the server using API https://xyz/ecms/cs.exe/api/v2/nodes/ in JavaScript.
Please see me source code below:
function fCreateDoc () {
var bodyData = {
type: "144",
parent_id: "8056220",
name: "Myfile123",
//file: "C:\04-02-2023\text.txt"
//file:'file=@"/C:/04-02-2023/text.txt"'
} formData = new FormData();
formData.append( "body", JSON.stringify( bodyData ) );
formData.append( "file", 'file=@"/C:/04-02-2023/text.txt"' );
return $.ajax( {
type: "POST",
url: "https://xyz/ecms/cs.exe/api/v2/nodes/",
data: bodyData,
contentType: "application/x-www-form-urlencoded",
headers: { otcsticket: localStorage.getItem("token") },
beforeSend: function( xhr ) {
xhr.overrideMimeType( "application/x-www-form-urlencoded" )
}
} ).then( function ( response ) {
alert("Success")
}, function ( jqxhr ) {
alert("failure :" + jqxhr.responseText)
} );
}
Getting error "An illegal attempt was made to upload a document"
Thank you for any help.