Genesys Cloud - Developer Community!

 View Only

Sign Up

  • 1.  Analytics API -- Python code Issue

    Posted 04-14-2025 21:59

    I used the dev portal with the json it works

    post /api/v2/analytics/conversations/details/query

    {
      "segmentFilters": [
        {
          "type": "or",
          "predicates": [
            {
              "type": "dimension",
              "dimension": "direction",
              "operator": "matches",
              "value": "inbound"
            }
          ]
        }
      ],
      "interval": "2025-04-01T00:00:00.000Z/2025-04-10T23:59:59.999Z"
    }

    but when i used python code, it doesn't. i am not sure what is the problem

    def get_conversation():
        body = PureCloudPlatformClientV2.ConversationQuery()
        segmentFilter = PureCloudPlatformClientV2.SegmentDetailQueryFilter()
     
        predicte01 = PureCloudPlatformClientV2.SegmentDetailQueryPredicate()
        predicte01.type = "dimension"
        predicte01.dimension = "direction"
        predicte01.operator = "matches"
        predicte01.values = ["inbound"]
        segmentFilter.predicates = [predicte01]
        segmentFilter.type = "or"
        body.segment_filters = segmentFilter
        body.interval='2025-04-01T00:00:00.000Z/2025-04-10T23:59:59.999Z'
     
        try:
            api_response = conversationApi.post_analytics_conversations_details_query(body)
            print(api_response)
            return "200 OK"
        except ApiException as e:
            print("Exception when calling ConversationApi %s\n" % e)

    error message: response body: {"message":"The request could not be understood by the server due to malformed syntax.","code":"bad.request","status":400,"contextId":"3c7c4d5f-f70b-4ada-8a41-aac0d4bc0c38","details":[],"errors":[]}


    #PlatformSDK

    ------------------------------
    Allan Zhao
    ------------------------------


  • 2.  RE: Analytics API -- Python code Issue

    Posted 04-15-2025 05:32

    Hello,

    You need to change:

    predicte01.values = ["inbound"] to predicte01.value = "inbound"

    body.segment_filters = segmentFilter to body.segment_filters = [segmentFilter]
    Regards,


    ------------------------------
    Jerome Saint-Marc
    Senior Development Support Engineer
    ------------------------------