Download report via REST API (or get data in some other way)

Hello,

When I download a .csv file of a report I see that it creates request to ` /youtrack/api/reports/83-551/export/csv`. Then if I try making request with curl but changing Authentication to Bearer <my-token> (instead of the cookie that my browser is using) I get this error:

```

{"error": "server_error","error_description": "Unknown principal 4d5612c4-c2f3-4ecd-a64b-b2fdf15a91a2"}

```

I'm working on a script that would automate creating my monthly invoice so I'd need to get my report data programmatically with php. Either I get it from a .csv file or with any other method I don't really care but looping through issues for worktime seems quite a lot of work for a task that in idea should be simple.

So can you point me somewhere where there is more info about calculating spent time / per user / per time period?

 

3 comments
Comment actions Permalink

Hi! 

I'm Sergey from the YouTrack team. 

When I download a .csv file of a report I see that it creates request to ` /youtrack/api/reports/83-551/export/csv`. Then if I try making request with curl but changing Authentication to Bearer <my-token> (instead of the cookie that my browser is using) 

This approach should work. I suggest checking that the user under which the token was created has access to the report. If it still doesn't work, please share the full request you make and your YouTrack version so I will test it in the same version. 

Other than that, iteration through the issues is the way to go.

We also have some ready to use solutions via a workflow: https://www.jetbrains.com/help/youtrack/incloud/generate-time-reports-workflow.html

0
Comment actions Permalink

Hello Sergey,

thank you for your reply. After your reply I've noticed that I really have a token problem and report works now.

Sorry for spamming :).

0
Comment actions Permalink

No problem at all! Glad to hear that the issue has been sorted out. 

0

Please sign in to leave a comment.