is it correct passing time frame as an object to resource management reports API?

Options

Hello,

When connecting to the report rows endpoint, I am receiving an error when using the timeframe as shown in the API documentation.

"time_frame":{ "from": "2022-01-01",

 "to":"2022-12-31"}

Error message received:

{'message': 'to is not a valid time_frame'}


I also tried to pass the 'from' and 'to' as a separate parameter without passing the 'time_frame' tag, I am also receiving an error.

any idea on how to pass the a date range to the time_frame parameter ?


The API works without error when using one of the canned strings such as:

  • this_week
  • this_month
  • this_quarter
  • this_year
  • last_week
  • last_month
  • last_quarter
  • last_year
  • next_30
  • next_60
  • next_90
  • last_30
  • last_60
  • last_90
  • last_and_next_90

Below is the screenshot when passing a string to the time frame - it works fine.


Below screenshot after passing the time frame as a date range object


Best Answer

  • Tamer Moustafa
    Tamer Moustafa ✭✭✭✭
    Answer ✓
    Options

    Hi @Genevieve P. ,

    I managed to do it, I am using Python and Jupyter notebook.

    This is how I made the request:

    the problem was that I was making the request like this :

    The point is when we have a parameter that is passed as an object (time_frame) then within the request we need pass the pramas like this (json = params) not (params = params).

    Please note that rq is an alias for the request (import request as rq)

Answers

  • Genevieve P.
    Options

    Hi @Tamer Moustafa

    Have you been able to resolve this? I am only currently able to test in Postman, and in my instance I'm able to get the Report with the time frame structured as follows:

    However I know in a previous Community post you mentioned in your program you need to write the Group By array in additional quotes for it to pass through. I am wondering if there's a similar format adjustment needed for the time frame parameters... for example, single quotation marks instead of double.

    Join us at Smartsheet ENGAGE 2024 🎉
    October 8 - 10, Seattle, WA | Register now

  • Tamer Moustafa
    Tamer Moustafa ✭✭✭✭
    Answer ✓
    Options

    Hi @Genevieve P. ,

    I managed to do it, I am using Python and Jupyter notebook.

    This is how I made the request:

    the problem was that I was making the request like this :

    The point is when we have a parameter that is passed as an object (time_frame) then within the request we need pass the pramas like this (json = params) not (params = params).

    Please note that rq is an alias for the request (import request as rq)

  • Genevieve P.
    Options

    Hey @Tamer Moustafa

    Thank you for coming back to explain how you achieved this! This is very helpful information to know for anyone else using both Python and Jupyter.

    Join us at Smartsheet ENGAGE 2024 🎉
    October 8 - 10, Seattle, WA | Register now