@Dmitry Bastron
I was trying to replicate your instructions using REST APIs but getting below error
CURL:-
curl --location --request POST 'https://localhost:44317/rest/cms.attachmenthistory/currentsite' \
--header 'Authorization: Basic YWRtaW46cGFzc3dvcmQ=' \
--header 'Content-Type: application/xml' \
--header 'Cookie: CMSPreferredCulture=en-US; ASP.NET_SessionId=mjv5bc5lu0x4ok1hcqkzzwwh' \
--data-raw '<CMS_AttachmentHistory>
<AttachmentName>vikasHMark2photo.png</AttachmentName>
<AttachmentExtension>.png</AttachmentExtension>
<AttachmentSize>3789</AttachmentSize>
<AttachmentImageWidth>629</AttachmentImageWidth>
<AttachmentImageHeight>280</AttachmentImageHeight>
<AttachmentMimeType>image/png</AttachmentMimeType>
<AttachmentGuid>76cc42af-0655-41a2-a87e-581e343bfb70</AttachmentGuid>
<AttachmentDocumentID>12558</AttachmentDocumentID>
<AttachmentGuid>0a4548f3-cd11-4d85-a32b-cc897d0a94a4</AttachmentGuid>
<AttachmentBinary>iVBORw0KGgoAAAANSUhEUgAAAnUAAAEYCAIAAAC1F5caAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAA5iSURBVHhe7d1tQuJIF4bhd10uyPW4GjfjYuYNSPcocJJK1VMQx+v6N91DSOXj3Eij/u8fACBNXwEgT18BIE9fASBPXwEgT18BIE9fASBPXwEgT18BIE9fASBPXwEgT18BIE9fASBPXwEgT18BIE9fASBPXwEgT18BIE9fASBPXwEgT18BIE9fASBPXwEgT18BIE9fASBPXwEgT18BIE9fASBPXwEgT18BIE9fASBPXwEgT18BIE9fASBPXwEgT18BIE9fASBPXwEgT18BIE9fASBPXwEgT18BIE9fASBPXwEgT18BIE9fASBPXwEgT18BIE9fASBPXwEgT18BIE9fASBPXwEgT18BIE9fASBPXwEgT18BIE9fASBPXwEgT18BIE9fASBPXwEgT18BIE9fASBPXwEgT18BIE9fASBPXwEgT18BIE9fASBPXwEgT18BIE9fASBPXwEgT18BIE9fASBP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NK89mtn9R1c5G53YVh5ZrcM75mn8VhOlrF31lsnLczx1u5dNONLBf2TlVBuXay+lnD40/c/+iHjK3n3QJrnjIVZCkr130ldn6p9vIFGpOTFDLjj1ospYH/b7BL2f7F1Wdpobyteu/AmedrwddBTn62kVfma4cbxs359AQ+uV9PSmPe6W7st2LKndRX49FX7voKw/QdXeOzaAn9LVpzx48Wdd/c+1du35c/afuRRUP1Nej0dcu+sojdNyegyPowX1dvvRr269nTNarX5veYGdjuxdVPFBfj0Zfu+grD7H7/hydQEcdCE+crDszuyOx3YsqHqivR6OvXfSVx9h5gxYDqH3sVjP12QPhAJP14/2t7U3j5p3qX9RD5vbItTDnfB3gKthHX7voKw+y6w4t/ucdX9VUMzX7ldF+x5msLZlt3K3+RT1kbo88ib6e6WsXfeVRdtyi43mtn05fv1kquxrZpsPVv6jikdHTNPQcc87X0a6CTfraRV95mGrO3dyjibwedSIccrKWBVq07NnAoh5wmoaeYs75OuRVsEZfu+grj1ON8aubNJLXuhnBr4w6HHWyloer5XgNLGr+aRp7hjnna85WJ9LXLvrKA1Wj7ttdmslr45M93HEn68DxGllUNblTga2W1bj9OefruFdBQV+76CuP1DDDU3k96Ew48GStTs72oR9ZVPWsocCWm2884nPO15ytTqSvXfSVh6rG3d/79P6N3HcbH3EoHHmydr+0GVpUdUlEAltdAs0HfM75OvJVcJe+dtFXHquappcbNZnXleka+dKoy5En63P6Wl4S40el3nLzBTDnfB35KrhLX7voKw9WzbzznZrN60pgnzYXDjxZ+3dtcFHVJbEYOi7l2d/x+mrO+TrwVXCfvnbRVx6uuFeXWzWd17UR+6TJcNzJWlWuoUWji6qe+qT3yKxsc88m55yvOVudSF+76CuPVwX2/g/HHbuFZ4zuK7t+Qfm8yfq55e7fMVdN0JYv9cYXVb8OWuw/OGtnfccXr4s552veVTCJvnbRV55gdZpeGb6DV2dtxy9j++vLDxhs38l5k/XrQd27rOKdg0VTjBKLWr8m2l82bP3Yx111nXW+9PV30FeeoT2wO8fhXauFXZxq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A8vQVAPL0FQDy9BUA8vQVAPL0FQDy9BUA8vQVAPL0FQDS/vnn/4tQFR7zy+2CAAAAAElFTkSuQmCC</AttachmentBinary> <!-- Insert base 64 encoded binary data -->
</CMS_AttachmentHistory>'
Message:
[DataConnection.HandleError]:
Query:
INSERT INTO CMS_AttachmentHistory ([AttachmentName], [AttachmentExtension], [AttachmentSize], [AttachmentMimeType], [AttachmentBinary], [AttachmentImageWidth], [AttachmentImageHeight], [AttachmentDocumentID], [AttachmentGUID], [AttachmentIsUnsorted], [AttachmentOrder], [AttachmentGroupGUID], [AttachmentHash], [AttachmentTitle], [AttachmentDescription], [AttachmentCustomData], [AttachmentLastModified], [AttachmentHistoryGUID], [AttachmentSiteID], [AttachmentSearchContent], [AttachmentVariantDefinitionIdentifier], [AttachmentVariantParentID])
VALUES (@AttachmentName, @AttachmentExtension, @AttachmentSize, @AttachmentMimeType, @AttachmentBinary, @AttachmentImageWidth, @AttachmentImageHeight, @AttachmentDocumentID, @AttachmentGUID, @AttachmentIsUnsorted, @AttachmentOrder, @AttachmentGroupGUID, @AttachmentHash, @AttachmentTitle, @AttachmentDescription, @AttachmentCustomData, @AttachmentLastModified, @AttachmentHistoryGUID, @AttachmentSiteID, @AttachmentSearchContent, @AttachmentVariantDefinitionIdentifier, @AttachmentVariantParentID);
SELECT SCOPE_IDENTITY() AS [ID]
Caused exception:
Cannot insert the value NULL into column 'AttachmentName', table 'OP_NOF_Kentico12.dbo.CMS_AttachmentHistory'; column does not allow nulls. INSERT fails.
The statement has been terminated.
Exception type: System.Exception
Stack trace:
at CMS.DataEngine.AbstractDataConnection.HandleError(String queryText, Exception ex)
at CMS.DataEngine.AbstractDataConnection.ExecuteQuery(String queryText, QueryDataParameters queryParams, QueryTypeEnum queryType, Boolean requiresTransaction)
at CMS.DataEngine.AbstractDataConnection.CMS.DataEngine.IDataConnection.ExecuteQuery(String queryText, QueryDataParameters queryParams, QueryTypeEnum queryType, Boolean requiresTransaction)
at CMS.DataEngine.GeneralConnection.RunQuery(QueryParameters query)
at CMS.DataEngine.GeneralConnection.RunQueryWithRetry(QueryParameters query, Int32 retryCount)
at CMS.DataEngine.GeneralConnection.ExecuteQuery(QueryParameters query)
at CMS.DataEngine.GeneralConnection.ExecuteQuery(QueryParameters query, Int32& totalRecords)
at CMS.DataEngine.DataQueryBase`1.GetDataFromDBInternal()
at CMS.DataEngine.DataQueryBase`1.GetDataFromDB()
at CMS.DataEngine.DataQueryBase`1.GetData()
at CMS.DataEngine.SimpleDataClass.Insert(Boolean initId)
at CMS.DataEngine.AbstractInfoBase`1.InsertDataInternal()
at CMS.DataEngine.AbstractInfoBase`1.InsertData()
at CMS.DataEngine.AbstractInfoBase`1.GeneralizedInfoWrapper.InsertData()
at CMS.DataEngine.AbstractInfoProvider`3.SetInfo(TInfo info)
at CMS.DocumentEngine.AttachmentHistoryInfoProvider.SetInfo(AttachmentHistoryInfo info)
at CMS.DocumentEngine.AttachmentHistoryInfo.SetObject()
at CMS.DataEngine.BaseInfo.SubmitChanges(Boolean withCollections)
at CMS.WebServices.BaseRESTService.SetObjectInternal(GeneralizedInfo info, String objectType, Stream stream, Boolean isCreate, String siteName)
at CMS.WebServices.RESTService.CreateCurrentSiteObject(String objectType, Stream stream)
at SyncInvokeCreateCurrentSiteObject(Object , Object[] , Object[] )
at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
at CMS.WebServices.RESTSecurityInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
Message: Cannot insert the value NULL into column 'AttachmentName', table 'OP_NOF_Kentico12.dbo.CMS_AttachmentHistory'; column does not allow nulls. INSERT fails.
The statement has been terminated.
Exception type: System.Data.SqlClient.SqlException
Stack trace:
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
at CMS.DataEngine.AbstractDataConnection.ExecuteQuery(String queryText, QueryDataParameters queryParams, QueryTypeEnum queryType, Boolean requiresTransaction)