Nicholas_Armaline | 2022-03-16 03:52:13 UTC | #1
I am trying to replicate a Conversations Aggregates Query I built with the Analytics Query Builder into my ASP.Net Project. Here is what I am trying to replicate:
[Code] { "interval": "2022-02-01T05:00:00.000Z/2022-03-01T05:00:00.000Z", "groupBy": ["wrapUpCode"], "filter": { "type": "and", "clauses": [ { "type": "and", "predicates": [ {"type": "dimension","dimension": "userId","operator": "matches","value": "b9882780-a4c2-43c1-95a6-3a41dd67b1fe" } ] }, { "type": "or", "predicates": [ {"type": "dimension","dimension": "wrapUpCode","operator": "matches","value": "d1451cef-3567-455d-8464-ea429defbe5d"}, {"type": "dimension","dimension": "wrapUpCode","operator": "matches","value": "afdbf2a2-1049-4c3a-b464-0446d3d06331"}, {"type": "dimension","dimension": "wrapUpCode","operator": "matches","value": "818852fc-addd-4f84-baab-2994fdb22883"} ] } ] }, "views": [], "metrics": ["tHandle"] } [/Code]
Here is my ASP.Net code
[code] Dim query As New ConversationAggregationQuery() query.Views = New List(Of ConversationAggregationView) query.Filter = New ConversationAggregateQueryFilter query.Filter.Type = ConversationAggregateQueryFilter.TypeEnum.And
Dim lPretWUC As New List(Of ConversationAggregateQueryPredicate) lPretWUC.Add(New ConversationAggregateQueryPredicate(Dimension:=ConversationAggregateQueryPredicate.DimensionEnum.Wrapupcode, Value:="d1451cef-3567-455d-8464-ea429defbe5d", _Operator:=ConversationAggregateQueryPredicate.OperatorEnum.Matches, Type:=ConversationAggregateQueryPredicate.TypeEnum.Dimension)) lPretWUC.Add(New ConversationAggregateQueryPredicate(Dimension:=ConversationAggregateQueryPredicate.DimensionEnum.Wrapupcode, Value:="afdbf2a2-1049-4c3a-b464-0446d3d06331", _Operator:=ConversationAggregateQueryPredicate.OperatorEnum.Matches, Type:=ConversationAggregateQueryPredicate.TypeEnum.Dimension)) lPretWUC.Add(New ConversationAggregateQueryPredicate(Dimension:=ConversationAggregateQueryPredicate.DimensionEnum.Wrapupcode, Value:="818852fc-addd-4f84-baab-2994fdb22883", _Operator:=ConversationAggregateQueryPredicate.OperatorEnum.Matches, Type:=ConversationAggregateQueryPredicate.TypeEnum.Dimension))
query.GroupBy = New List(Of ConversationAggregationQuery.GroupByEnum) query.GroupBy.Add(ConversationAggregationQuery.GroupByEnum.Wrapupcode)
query.Metrics = New List(Of ConversationAggregationQuery.MetricsEnum) query.Metrics.Add(ConversationAggregationQuery.MetricsEnum.Thandle) Dim dMonth As Date = CDate(ddMonth.SelectedValue) query.Interval = "2022-02-01T00:00:000Z/2022-03-01T00:00:000"
Dim lPretUserId As New List(Of ConversationAggregateQueryPredicate) Dim pretUserid As New ConversationAggregateQueryPredicate(Dimension:=ConversationAggregateQueryPredicate.DimensionEnum.Userid, Value:=oUser.Id = "bd7c2511-0a05-48dd-9223-b744339a72d8", _Operator:=ConversationAggregateQueryPredicate.OperatorEnum.Matches, Type:=ConversationAggregateQueryPredicate.TypeEnum.Dimension) lPretUserId.Add(pretUserid) 'clear out predicate and readd then to the query query.Filter.Clauses = New List(Of ConversationAggregateQueryClause) query.Filter.Clauses.Add(New ConversationAggregateQueryClause(Type:=ConversationAggregateQueryFilter.TypeEnum.And, Predicates:=lPretUserId)) query.Filter.Clauses.Add(New ConversationAggregateQueryClause(Type:=ConversationAggregateQueryFilter.TypeEnum.Or, Predicates:=lPretWUC))
Dim oUserWUC = aApi.PostAnalyticsConversationsAggregatesQuery(query).Results [/Code]
On the last line, I get the following error:
Error calling PostAnalyticsConversationsAggregatesQuery:
{"message":"The request could not be understood by the server due to malformed syntax.",
"code":"bad.request",
"status":400,
"contextId":"8ccc918d-b3c6-4d7f-a7f4-58c34a49f411",
"details":[],
"errors":[]}
What am I doing wrong? When i do Query.ToJson, it matches up almost perfectly.
Thanks ahead of time.
ralegner | 2022-03-15 20:34:22 UTC | #2
Nicholas_Armaline, post:1, topic:13932"] "grouBy": ["wrapUpCode
,
Typo here. It should be groupBy. Sometimes it just takes a second set of eyes to catch the small stuff. :grinning:
Nicholas_Armaline | 2022-03-15 22:30:22 UTC | #3
's not the JSON I need help with...it's the ASP.Net code...and the typo is from me trying to make it look pretty instead of a train wreck. The line that would generate that is ASP.Net is:
query.GroupBy.Add(ConversationAggregationQuery.GroupByEnum.Wrapupcode)
Jerome.Saint-Marc | 2022-03-16 17:45:05 UTC | #4
Hello,
I think that your 400 error is coming from the query interval.
The format you are using is wrong/invalid: query.Interval = "2022-02-01T00:00:000Z/2022-03-01T00:00:000" You have 3 zeros for seconds.
Use the following format (2 digits for seconds): query.Interval = "2022-02-01T00:00:00Z/2022-03-01T00:00:00Z" or (seconds and milliseconds query.Interval = "2022-02-01T00:00:00.000Z/2022-03-01T00:00:00.000Z"
Regards,
Nicholas_Armaline | 2022-03-16 17:45:54 UTC | #5
Thank you for your help Jerome
system | 2022-04-16 17:46:39 UTC | #6
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
This post was migrated from the old Developer Forum.
ref: 13932