Rest Api Table - Inserting values for datetime columns

Hi,

I'm trying to insert a record into an extra table using the TableRecord endpoint.

I get the following error message when including a datetime column 

{
  "Error": true,
  "ErrorType": "SoInvalidArgumentException",
  "Message": "When doing an insert on a date-field you need to use the System.DateTime as parameter!No other values (for example String or Int) are accepted! Source: SuperOffice.Data.SQL.ArgumentParameterCollection Expected: 'System.DateTime' Recieved: 'System.RuntimeType'.",
  "ErrorSource": "SoDataBase"
}
 
How should the payload be formatted to correctly insert a datetime?
 
{
"x_person": 226421,
"x_nps": 2,
"x_ticket_category": 421,
"x_score": 5,
"x_cust_replied": "2014-09-27T18:30:49-0300" -- Not working
}
 
/ Peter

RE: Rest Api Table - Inserting values for datetime columns

Hello Peter,

The string values need to be 'encoded' so that the API understands with kind of value it is (datetime, double, etc).

When using the .NET proxy you can use a build in function for this, but since you are using the REST-api that isn't possible.

Encoding works as follows:

Int value 421 = [I:421]

Date value '2014-09-27' = [D:09/27/2014]

DateTime value '2014-09-27T18:30:49-0300' = [DT:09/27/2014 21:30:49.0000000]

Double value 24.50 = [F:24.5]

 

Av: David Hollegien 2. jan 2020

RE: Rest Api Table - Inserting values for datetime columns

Nice, thanks David!

Av: Frode Lillerud 11. aug 2021