Taiga Export using REST API... How to get the exported JSON project object URL?

249 views
Skip to first unread message

ric...@gmail.com

unread,
Apr 17, 2016, 8:36:47 PM4/17/16
to taigaio
Hello All,

According to the API documentation for project export (Section 35.1: https://taigaio.github.io/taiga-doc/dist/api.html#export-import-export-dump), it states:

Depending on server configuration it can return two results:
 
A 202 Accepted and as response body a JSON of export request accepted.
A 200 OK and as response body a JSON of export detail for synch mode. 
 

So I have two questions:

  • What is the server configuration dependency that determines either a HTML return code of 200 or 202?
I wonder if this has to do with whether asynchronous functionality is enabled in the Taiga backend (see Section 3.5 Asynch Tasks: https://taigaio.github.io/taiga-doc/dist/setup-production.html).
 

And my second question is if Taiga returns the following JSON return object (which would happen on a return code of 202):


{
    "export_id": "e338555a-3918-4203-8fc6-81b3f7933c79"
}
 
  • What is this? How do I use this to access the exported JSON project object (typically provided through the "url" JSON return object)? 

Perhaps this export_id return object can be used to query into the REST API to then get access to the export JSON project object, but I don't see any documentation that makes use of this export_id return object.


What I want to do is programmatically (e.g., via automated script) query into the REST API and periodically download the exported JSON project object (the same JSON object returned via email). I'm not sure how to do this with the export_id return object (I can do this with the URL return object, of course).


As always, thanks much.

Rich


Alejandro Alonso

unread,
Apr 18, 2016, 3:07:38 AM4/18/16
to Rich Bloch, taigaio
Hello!,
  • What is the server configuration dependency that determines either a HTML return code of 200 or 202?
I wonder if this has to do with whether asynchronous functionality is enabled in the Taiga backend (see Section 3.5 Asynch Tasks: https://taigaio.github.io/taiga-doc/dist/setup-production.html).

You are right, if Taiga is working in asynchronous mode you will receive an email when the project is correctly exported, that email contains the link to download the project.
 
And my second question is if Taiga returns the following JSON return object (which would happen on a return code of 202):


{
    "export_id": "e338555a-3918-4203-8fc6-81b3f7933c79"
}
 
  • What is this? How do I use this to access the exported JSON project object (typically provided through the "url" JSON return object)? 

Perhaps this export_id return object can be used to query into the REST API to then get access to the export JSON project object, but I don't see any documentation that makes use of this export_id return object.

That export_id can be used to build the URL to download the exported file when ready, it should be something like: MEDIA_URL/exports/PROJECT_ID/PROJECT_SLUG-export_id.json

What I want to do is programmatically (e.g., via automated script) query into the REST API and periodically download the exported JSON project object (the same JSON object returned via email). I'm not sure how to do this with the export_id return object (I can do this with the URL return object, of course).

If you are executing this automated script against the REST API I think you could take another approach. If you can manage your own email domain, you could create a project member with admin privileges just to use it for exporting, when the email containing the export result arrives to that account your script could just download the file. Another approach could be just checking that account periodically, if there is a new email just download the file and remove the email from the inbox. 

Regards,

--

  
Alejandro Alonso Fernández  
CIO & Co-founder

www.kaleidos.net/FC8EAC/

Rich Bloch

unread,
Apr 18, 2016, 10:20:59 AM4/18/16
to Alejandro Alonso, taigaio
Thanks for the response and very useful information, Alejandro.

I particularly think using export_id to build a download URL out of MEDIA_URL is an interesting idea. It never occurred to me that export_id is treated like a hash value in the JSON filename (I suppose I could've looked at the filename of the downloaded file and figured that out). Thanks for that!

Rich

Alejandro Alonso

unread,
Apr 19, 2016, 2:09:26 AM4/19/16
to Rich Bloch, taigaio
I think we should update the doc with that part, it's not very obvious :)

Regards!,
Reply all
Reply to author
Forward
0 new messages