Export and import translation ZIP via REST API

Comments

5 comments

  • Avatar
    Johanna Linaker (K15t)

    Hi Volker,

    We were able to reproduce the behaviour you are describing, and believe we have found the reason for why this is happening. The reason for why you are receiving the following response:

     {"id":"C0A8A0B101745301E7B0E8B516929DAE","clusterNo":-1,"startTimestamp":1599120467896,"completionTimestamp":1599120468179,"started":true,"cancelled":false,"hasFailed":false,"finished":true,"failureMessage":null,"progress":0,"message":"Die Aufgabe 'Übersetzung exportieren' befindet sich noch in der Warteschlange.","resourceLocation":null}

     
    Is because you are asking for a response which Confluence has already provided. The first response you get where the finished flag is set to true, is the response which contains all the information about the exported file. If you continue asking Confluence for a status after the first finished response has already been provided, the final response will be the one you mentioned above.

    Therefore, it should be enough if you ask Confluence for the status until you get this first one response where the finished flag is set to true and use this response.

    Another alternative could also be to export through the browser and have a look at the network tab. There you will see how the last response contains all the information. Calling the status url again after that leads to the confusing response mentioned above.

    Does this make sense?

    Cheers,
    Johanna (K15t).

    0
    Comment actions Permalink
  • Avatar
    Volker Weinreich

    Hello Johanna,

    thanks for your response.

    I still don't know how to achieve this. Do I have to put a timestamp into the request? And what timestamp should it be?

    Of course I can see in the network tab what Confluence is doing, If I run the export through the browser, and there I can see the information I need. I also tried to send the request again from the browser (firefox) or from the REST API Browser of Confluence, but with the same effect -> task in queue.

    My aim is to automate the process (with some batches or something), so I need to evaluate every response for a next request and so on. For example I was able to create a GET request, which creates a json-file with version ID for a given name of the version. I am using this json for the POST request, which we are talking about in this ticket. The POST request itself works: I can see, that Confluence creates a zip in a temp folder, but I can't get the file information for my GET request.

    Do I have to fire the GET request permanently during the process to get the information?

    I would be very grateful if you could help me further here.

    Greetings,

    Volker

    0
    Comment actions Permalink
  • Avatar
    K15t Team

    Hi Volker,

    sorry for the confusion. I had a look at this again and I think I can explain now:

    Yes, the last GET request you are using for checking the status of the task is supposed to be pulled constantly until the task is finished. 

    I just confirmed that only within a couple seconds after the task is done, you can access the information for the translation file. 
    After those few seconds, if you send a request to that resource you will get the incorrect reply you got above (saying that the task is queued).

    So after starting the export task through the POST request initially, you have to make sure to call the resource for the task status once a second or so until its done - then you will get the information you need.

    Please let me know if this is what you were looking for.

    Cheers,
    Peter

    0
    Comment actions Permalink
  • Avatar
    Volker Weinreich (Edited )

    Hello Peter,

    okay, I understand and was able to reproduce it manually with Postman - by clicking fast :-)

    Since I am not a programmer, I have to see how I can get an automatism here that returns the taskid from the POST request and inserts it milliseconds later in the GET request.

    Thanks,

    Volker

    0
    Comment actions Permalink
  • Avatar
    Volker Weinreich

    Hi,

    just in case anyone else is interested: You can use a pre-request to check when to run the GET request to get "fileId" and "fileName". You can control the delay time and the number of retries of the request.

    For more information see https://stackoverflow.com/questions/43295102/postman-how-to-loop-request-until-i-get-a-specific-response.

    Many greetings,

    Volker

     

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk