Hello! I have a Desktop Application that is responsible for pushing data from the local database to the ERPNext server. There is a document of ERPNext Timesheet
. The question is that I want to put a new record of the child table of Timesheet like time_logs
. But if I use the POST request its response will be {}
just blank and no new row is created. But if I use a PUT request, it changes the previous child row. I want to create a new row since the parent document is in draft.
Below is my code.
{
"activity_type": "Communication",
"from_time": "2024-01-15 11:50:20",
"description": "Administrator",
"project": "PROJ-0001",
"to_time": "2024-01-15 11:50:36"
}
string timesheet = @"{";
string str = @"
""activity_type"": ""vactivity_type"",
""from_time"": ""vfrom_time"",
""description"": ""vdescription"",
""project"": ""vproject"",
""to_time"": ""vto_time""
";
RestRequest restRequest = new RestRequest($"/api/resource/Timesheet/TS-2024-00001/time_logs", Method.POST);
str = str.Replace("vactivity_type", "Communication"/*row["activity_type"].ToString()*/);
str = str.Replace("vfrom_time", Convert.ToDateTime(row["from_time"]).ToString("yyyy-MM-dd HH:mm:ss"));
str = str.Replace("vdescription", row["description"].ToString());
str = str.Replace("vproject", row["project"].ToString());
str = str.Replace("vto_time", Convert.ToDateTime(row["to_time"]).ToString("yyyy-MM-dd HH:mm:ss"));
timesheet += string.Concat(str, "}");
restRequest.AddParameter("data", timesheet);
IRestResponse restResponse = restClient.Execute(restRequest);
Please guide me on this. Thanks in advance.