Integrations and APIs for Service

Get Involved. Join the Conversation.

Topic

    Patrick Blascheck
    how can I add a filter to a report when querying via python...Answered
    Topic posted November 13, 2018 by Patrick Blascheck, tagged REST 
    61 Views, 2 Comments
    Title:
    how can I add a filter to a report when querying via python request
    Summary:
    I'm able to get a report but I can't change the filter of it
    Content:

    Hi,

    I use:

    import requests as r

    url= 'https://***.custhelp.com/services/rest/connect/v1.3/analyticsReportResults'
    r_get = r.post(url, json = {"id": 103582} , auth=('user', pw)).json()
    print(r_get)

    to successfully receive the fist 10k lines of a report. I tried to add a filter like:

    r_get = r.post(url, json = {"id": 103582, "filters" : [{"name": "Created","operator": [{"id": 9}],"values": [{"0": "1541673423","1": "1541673423"}]}]} , auth=('user', pw)).json()

    or similar but I only get: "A problem setting a property was encountered: Invalid ObjectType: 6" or "Invalid property specified:.."

    Is there a way to change the pre-set filters? I would not want to create multiple reports jsut to vary the date

    Thank you and kind regards

    Patrick

     

     

    Version:
    1.3
    Code Snippet:

    Best Comment

    Neil

    'values' needs to be an array, invalid Objecttype is because it's an object in your JSON. Try the following:

     

    { "id": 103582, "filters": [ { "name": "Created", "operator": [ { "id": 9 } ], "values": [ "1541673423", "1541673423" ] } ] }

    Comment

     

    • Neil

      'values' needs to be an array, invalid Objecttype is because it's an object in your JSON. Try the following:

       

      { "id": 103582, "filters": [ { "name": "Created", "operator": [ { "id": 9 } ], "values": [ "1541673423", "1541673423" ] } ] }