Resource Managment API - Reports
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'}
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
I'm using Python and the request package here is the basic code:
response = requests.post('https://api.rm.smartsheet.com/api/v1/reports/rows',
headers={
"Content-Type": "application/json",
"auth":token,
}, params={
"view":'time_fees_hours',
"time_frame":{
"from": "2022-01-01",
"to":"2022-12-31"}
})
print(response.json())
Any help is greatly appreciated.
Cheers!
Answers
-
Hi @Dataman
Can you test removing "time_frame": from this request (but keeping the dates in)?
In my testing, "time_frame" was only needed if I was specifying one of the canned strings you have mentioned above, but when identifying specific dates it was not needed.
If this works for you, I'll put in a request to have the API Documentation updated as I can see that it puts "time_frame": before the From and To when identifying specific dates.
Cheers,
Genevieve
Need more help? 👀 | Help and Learning Center
こんにちは (Konnichiwa), Hallo, Hola, Bonjour, Olá, Ciao! 👋 | Global Discussions
-
Thanks for your response. I've removed the time_frame tag as you suggested. So the request just looks like:
The API response has the set the default option to "time_frame": "this_week" regardless if I put this tag in or not. Additionally, the actual range in the dates section does not update to my custom range.
Thanks,
Dataman
-
Hi @Dataman
I have to admit I'm not sure if what you're seeing is expected or not; please submit your findings to our RM Support team through this form, here. They'll be able to work with you directly in a private channel and identify if this is a bug and needs to be fixed, or expected and the documentation should be updated.
Thank you!
Genevieve
Need more help? 👀 | Help and Learning Center
こんにちは (Konnichiwa), Hallo, Hola, Bonjour, Olá, Ciao! 👋 | Global Discussions
-
I also seem to be running into a similar issue where the parameters provided in the body of the request are ignored and it is defaulting them. Could you please advise if there were any updates on this?
-
Hi @NNPPC , You need to pass the group_by Parameter as a string' - (Put quotes for the array)
{'view': 'time_fees_hours',
'group_by': '["project_id", "user_id"]' }
-
Hello, @Dataman , @NNPPC , @Genevieve P.
Did you manage to solve the time frame tag ? I have the same issue, whatever I pass it returns the default value "this week", I need to pass date range.
any advise ?
-
I didn't see an answer here so I'll post working python code:
custom_timeframe = { "from": "2024-04-24", "to": "2024-04-30" } report_parameters = { "view": "time_fees_hours", "time_frame": custom_timeframe, "group_by": ["project_id"], "today": "{}".format(datetime.today().strftime('%Y-%m-%d')), } [snip]
You can troubleshoot these payloads by inspecting the page on the website, running the report you want, then looking at the network tab. Here's the payload from the browser.
{ "view": "time_fees_hours", "time_frame": { "from": "2024-04-24", "to": "2024-04-30" }, "group_by": [ "project_id" ], "today": "2024-04-23" }
Categories
- All Categories
- 14 Welcome to the Community
- Customer Resources
- 64.9K Get Help
- 439 Global Discussions
- 138 Industry Talk
- 471 Announcements
- 4.9K Ideas & Feature Requests
- 129 Brandfolder
- 148 Just for fun
- 67 Community Job Board
- 486 Show & Tell
- 33 Member Spotlight
- 2 SmartStories
- 300 Events
- 36 Webinars
- 7.3K Forum Archives