Question

DataService - Error providing value for DateTime field "Error parsing comment. Expected: *, got D."

I am using the DataService from a C# application. I am using the Terrasoft libraries to build my InsertQuery object and submit it to my BPM instance. Everything it generates works fine until I attempt to specify a value for a DateTime field. The error message I get back looks like this:

{
	"success" : false,
	"responseStatus" : {
		"ErrorCode" : "JsonReaderException",
		"Message" : "Error parsing comment. Expected: *, got D. Path '', line 1, position 1.",
		"Errors" : [
		]
	},
	"rowsAffected" : -1,
	"nextPrcElReady" : false
}

My date value gets formatted in the following manner:

"Value" : "\/Date(1258761605000)\/"

Here is my entire json payload submitted to the InsertQuery endpoint - for the Activity table:

{
	"ColumnValues" : {
		"Items" : {
			"Title" : {
				"ExpressionType" : 2,
				"ColumnPath" : null,
				"Parameter" : {
					"DataValueType" : 1,
					"Value" : "Asset Allocation",
					"ArrayValue" : null,
					"ShouldSkipConvertion" : false
				},
				"FunctionType" : 0,
				"MacrosType" : 0,
				"FunctionArgument" : null,
				"DatePartType" : 0,
				"AggregationType" : 0,
				"AggregationEvalType" : 0,
				"SubFilters" : null
			},
			"StartDate" : {
				"ExpressionType" : 2,
				"ColumnPath" : null,
				"Parameter" : {
					"DataValueType" : 7,
					"Value" : "\/Date(1258761605000)\/",
					"ArrayValue" : null,
					"ShouldSkipConvertion" : false
				},
				"FunctionType" : 0,
				"MacrosType" : 0,
				"FunctionArgument" : null,
				"DatePartType" : 0,
				"AggregationType" : 0,
				"AggregationEvalType" : 0,
				"SubFilters" : null
			},
			"DueDate" : {
				"ExpressionType" : 2,
				"ColumnPath" : null,
				"Parameter" : {
					"DataValueType" : 7,
					"Value" : "\/Date(1258832544000)\/",
					"ArrayValue" : null,
					"ShouldSkipConvertion" : false
				},
				"FunctionType" : 0,
				"MacrosType" : 0,
				"FunctionArgument" : null,
				"DatePartType" : 0,
				"AggregationType" : 0,
				"AggregationEvalType" : 0,
				"SubFilters" : null
			},
			"Type" : {
				"ExpressionType" : 2,
				"ColumnPath" : null,
				"Parameter" : {
					"DataValueType" : 10,
					"Value" : "fbe0acdc-cfc0-df11-b00f-001d60e938c6",
					"ArrayValue" : null,
					"ShouldSkipConvertion" : false
				},
				"FunctionType" : 0,
				"MacrosType" : 0,
				"FunctionArgument" : null,
				"DatePartType" : 0,
				"AggregationType" : 0,
				"AggregationEvalType" : 0,
				"SubFilters" : null
			},
			"ActivityCategory" : {
				"ExpressionType" : 2,
				"ColumnPath" : null,
				"Parameter" : {
					"DataValueType" : 10,
					"Value" : "8f4d293b-761f-4bbf-b048-d6a4aad92e21",
					"ArrayValue" : null,
					"ShouldSkipConvertion" : false
				},
				"FunctionType" : 0,
				"MacrosType" : 0,
				"FunctionArgument" : null,
				"DatePartType" : 0,
				"AggregationType" : 0,
				"AggregationEvalType" : 0,
				"SubFilters" : null
			},
			"Status" : {
				"ExpressionType" : 2,
				"ColumnPath" : null,
				"Parameter" : {
					"DataValueType" : 10,
					"Value" : "4bdbb88f-58e6-df11-971b-001d60e938c6",
					"ArrayValue" : null,
					"ShouldSkipConvertion" : false
				},
				"FunctionType" : 0,
				"MacrosType" : 0,
				"FunctionArgument" : null,
				"DatePartType" : 0,
				"AggregationType" : 0,
				"AggregationEvalType" : 0,
				"SubFilters" : null
			},
			"Notes" : {
				"ExpressionType" : 2,
				"ColumnPath" : null,
				"Parameter" : {
					"DataValueType" : 1,
					"Value" : "Some notes, blah blah",
					"ArrayValue" : null,
					"ShouldSkipConvertion" : false
				},
				"FunctionType" : 0,
				"MacrosType" : 0,
				"FunctionArgument" : null,
				"DatePartType" : 0,
				"AggregationType" : 0,
				"AggregationEvalType" : 0,
				"SubFilters" : null
			},
			"DurationInMinutes" : {
				"ExpressionType" : 2,
				"ColumnPath" : null,
				"Parameter" : {
					"DataValueType" : 4,
					"Value" : 15,
					"ArrayValue" : null,
					"ShouldSkipConvertion" : false
				},
				"FunctionType" : 0,
				"MacrosType" : 0,
				"FunctionArgument" : null,
				"DatePartType" : 0,
				"AggregationType" : 0,
				"AggregationEvalType" : 0,
				"SubFilters" : null
			}
		}
	},
	"RootSchemaName" : "Activity",
	"OperationType" : 0
}

What am I doing wrong? Thank you.

Like 0

Like

6 comments
Best reply

Eugene Podkovka,

Thank you! this is working! It would be really helpful if you could update your docs to include a DateTime field like this in your example code.

DataService is a very complicate thing. Especially with a proxy class and bpm'online libraries. It's hard to find the cause of the issue by the request body. It would have been much easier if you have used OData web http requests. 

Back to the question. Please take a backup of your application from the bpm'online support and an out-of-the-box archive with the application of the same version and the product as the one that you have. Deploy the application on your side, restore the production backup and debug it. 

https://academy.bpmonline.com/documents/technic-sdk/7-11/server-code-de…

This way you'll find the cause of the issue.

Eugene Podkovka,

Thank you for your reply. I understand that OData is much easier to use. We have already built our solution on OData - however we are building a product integration where speed is one of the most important factors and in our tests DataService is 4-5x faster than OData. So, we are attempting to switch to DataService.

I do not have the environment setup necessary to do server-side debugging as you suggest in your reply (I'm using a bpmonline.com instance). However - I am using all out-of-the-box BPM components and am following the sample code provided in your documentation (except there is no example of using DateTime fields). I have no issue with any other field types. Shouldn't it work?

I found a reference to a similar issue here https://community.bpmonline.com/questions/datetime-format-dataservice , however it looks like that user got his solution to work using the same format as what is being generated by my code. So I'm not sure why this format works for him but not for me..

Could it be a version difference between my proxy components and the server I'm hitting? (has this format changed lately?)

Should I open a case with support?

I did notice I had a version difference between the proxy dll's and the server version. I upgraded, but it generates the same JSON - and still throws the same error.

The correct format is 

value="2018-02-06T15:13:42.000"

You can generate it with the following code expression

var usrTestDate = new ColumnExpression

            {

                ExpressionType = EntitySchemaQueryExpressionType.Parameter,

                Parameter = new Parameter

                {

                    Value = String.Format("\"{0:s}\"", DateTime.Now),

                    DataValueType = DataValueType.DateTime

                }

            };

insertQuery.ColumnValues.Items.Add("UsrTestDate", usrTestDate);

var json = new JavaScriptSerializer().Serialize(insertQuery);

Eugene Podkovka,

Thank you! this is working! It would be really helpful if you could update your docs to include a DateTime field like this in your example code.

Eugene Podkovka,

Thank you! this is working.

Show all comments