Create the Translations ZIP File via REST API

Comments

7 comments

  • Avatar
    Pavel (Edited )

    Hi Roman!
    I got the good result with "provider":"simple", but with "provider":"xliff" I got an error:

    Task:

    {"id":"0A65690701636383A4194A737DE03DCA","clusterNo":-1,"startTimestamp":1526382961705,"completionTimestamp":1526382961937,"started":true,"cancelled":false,"hasFailed":true,"finished":true,"failureMessage":{"severity":"Error","message":"OneFilePerPage=false not supported for XLIFF translation provider","stackTrace":"java.lang.RuntimeException: OneFilePerPage=false not supported for XLIFF translation provider\n\tat com.k15t.scroll.platform.model.translation.provider.file.xliff.XliffTranslationFileProvider.createTranslationFileForMultiplePages(XliffTranslationFileProvider.java:73)\n\tat com.k15t.scroll.platform.model.translation.provider.file.AbstractTranslationFileProvider.startTranslation(AbstractTranslationFileProvider.java:171)\n\tat com.k15t.scroll.platform.ui.translation.StartTranslationTask.doExecute(StartTranslationTask.java:31)\n\tat com.k15t.scroll.platform.ui.translation.StartTranslationTask.doExecute(StartTranslationTask.java:17)\n\tat com.k15t.scroll.platform.model.task.AbstractTransactionalTask$1.doInTransaction(AbstractTransactionalTask.java:31)\n\tat com.atlassian.sal.core.transaction.HostContextTransactionTemplate$1.doInTransaction(HostContextTransactionTemplate.java:21)\n\tat com.atlassian.sal.spring.component.SpringHostContextAccessor$1.doInTransaction(SpringHostContextAccessor.java:71)\n\tat org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133)\n\tat com.atlassian.sal.spring.component.SpringHostContextAccessor.doInTransaction(SpringHostContextAccessor.java:68)\n\tat com.atlassian.confluence.spring.transaction.interceptor.ConfluenceSpringHostContextAccessor.access$001(ConfluenceSpringHostContextAccessor.java:21)\n\tat com.atlassian.confluence.spring.transaction.interceptor.ConfluenceSpringHostContextAccessor.lambda$doInTransaction$3(ConfluenceSpringHostContextAccessor.java:72)\n\tat com.atlassian.confluence.impl.vcache.VCacheRequestContextManager.doInRequestContextInternal(VCacheRequestContextManager.java:87)\n\tat com.atlassian.confluence.impl.vcache.VCacheRequestContextManager.doInRequestContext(VCacheRequestContextManager.java:71)\n\tat com.atlassian.confluence.spring.transaction.interceptor.ConfluenceSpringHostContextAccessor.doInTransaction(ConfluenceSpringHostContextAccessor.java:72)\n\tat sun.reflect.GeneratedMethodAccessor250.invoke(Unknown Source)\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n\tat java.lang.reflect.Method.invoke(Method.java:498)\n\tat com.atlassian.plugin.util.ContextClassLoaderSettingInvocationHandler.invoke(ContextClassLoaderSettingInvocationHandler.java:26)\n\tat com.sun.proxy.$Proxy311.doInTransaction(Unknown Source)\n\tat sun.reflect.GeneratedMethodAccessor250.invoke(Unknown Source)\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n\tat java.lang.reflect.Method.invoke(Method.java:498)\n\tat com.atlassian.plugin.osgi.bridge.external.HostComponentFactoryBean$DynamicServiceInvocationHandler.invoke(HostComponentFactoryBean.java:136)\n\tat com.sun.proxy.$Proxy311.doInTransaction(Unknown Source)\n\tat com.atlassian.sal.core.transaction.HostContextTransactionTemplate.execute(HostContextTransactionTemplate.java:18)\n\tat sun.reflect.GeneratedMethodAccessor5272.invoke(Unknown Source)\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n\tat java.lang.reflect.Method.invoke(Method.java:498)\n\tat org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302)\n\tat org.eclipse.gemini.blueprint.service.importer.support.internal.aop.ServiceInvoker.doInvoke(ServiceInvoker.java:56)\n\tat org.eclipse.gemini.blueprint.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.java:60)\n\tat org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)\n\tat org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133)\n\tat org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121)\n\tat org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)\n\tat org.eclipse.gemini.blueprint.service.util.internal.aop.ServiceTCCLInterceptor.invokeUnprivileged(ServiceTCCLInterceptor.java:70)\n\tat org.eclipse.gemini.blueprint.service.util.internal.aop.ServiceTCCLInterceptor.invoke(ServiceTCCLInterceptor.java:53)\n\tat org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)\n\tat org.eclipse.gemini.blueprint.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:57)\n\tat org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)\n\tat org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133)\n\tat org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121)\n\tat org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)\n\tat org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208)\n\tat com.sun.proxy.$Proxy2748.execute(Unknown Source)\n\tat com.k15t.scroll.platform.model.task.AbstractTransactionalTask.execute(AbstractTransactionalTask.java:28)\n\tat com.k15t.scroll.platform.model.task.impl.DefaultAsyncTask.call(DefaultAsyncTask.java:232)\n\tat java.util.concurrent.FutureTask.run(FutureTask.java:266)\n\tat java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)\n\tat java.util.concurrent.FutureTask.run(FutureTask.java:266)\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)\n\tat java.lang.Thread.run(Thread.java:745)\n"},"progress":0,"message":"Collecting pages for new translation in 'Datamart (ru)' (DMRU).","resourceLocation":null}

    Error: 

    "message":"OneFilePerPage=false not supported for XLIFF translation provider"

    Parameters:

    {"languageKey":"en","outdatedOnly":"false","provider":"xliff","spaceKey":"DMRU", "versionId":"0A65690701627647BC8A763C746B7F0C"}

    How can I define this parameter?

    1
    Comment actions Permalink
  • Avatar
    Roman Serazhiev

    Hi Pavel.

    I could start the translation ZIP via REST without issues. Here is the raw request:

    POST /rest/scroll-versions/1.0/translation/start HTTP/1.1
    Authorization: Basic YWRtaW46YWRtaW4=
    Content-Type: application/json; charset=utf-8
    Host: conf69:8111
    Connection: close
    User-Agent: Paw/3.1.7 (Macintosh; OS X/10.13.4) GCDHTTPRequest
    Content-Length: 86

    {"languageKey":"it","outdatedOnly":"false","provider":"xliff","spaceKey":"romantest1"}

     

    And here is the raw response:

    HTTP/1.1 202 Accepted
    Server: Apache-Coyote/1.1
    X-ASEN: SEN-L9384919
    Set-Cookie: JSESSIONID=C30E8A19F0F73A9D939C94280A202D5C; Path=/; HttpOnly
    X-Seraph-LoginReason: OK
    X-AUSERNAME: admin
    X-Content-Type-Options: nosniff
    Content-Type: application/json
    Transfer-Encoding: chunked
    Date: Tue, 15 May 2018 08:59:59 GMT
    Connection: close

    {"id":"7F0000010163630719F8743C31B9AF94","clusterNo":-1,"started":false,"cancelled":false,"hasFailed":false,"finished":false,"failureMessage":null,"progress":0,"message":"The task 'New translation' is currently queued.","resourceLocation":null}

     

    Here is the article I used to generate the request: https://help.k15t.com/scroll-translations/latest/export-and-import-translation-zip-via-rest-api-121308407.html

    Let me know if it helps.

     

    Cheers,
    Roman.

    0
    Comment actions Permalink
  • Avatar
    Pavel

    Roman Thanks!

    Add information to the article about the type of data "Content-Type: application/json".

    Now the article says "The body consists of a form-data..." I understand this type of data as "Content-Type:application/x-www-form-urlencoded" or "Content-Type:multipart/form-data"

    - Pavel

    0
    Comment actions Permalink
  • Avatar
    Roman Serazhiev

    Hi Pavel.

    Thanks for pointing out the missing content-type information. I have added it to the article.

    When using xliff as file provider, only "One file per page" is supported. Which API endpoint are you using when you are getting this error? When I send POST request to /rest/scroll-versions/1.0/translation/start with xliff provider, I don't specify OneFilePerPage, and it works.

    Cheers,
    Roman.

    0
    Comment actions Permalink
  • Avatar
    Pavel

    Hi Roman!

    I do not use this "One file per page" parameter in any way. But the error is related to this parameter. And in mode "simple", we can set it through user interface.

    Step to error:

    1. POST request to /rest/scroll-versions/1.0/translation/start

    Parameters:

    {"languageKey":"en","outdatedOnly":"false","provider":"xliff","spaceKey":"DMRU", "versionId":"0A65690701627647BC8A763C746B7F0C"}

    Response:

    {"id":"0A656907016363F941F9775C308A600F","clusterNo":-1,"started":false,"cancelled":false,"hasFailed":false,"finished":false,"failureMessage":null,"progress":0,"message":"The task 'New translation' is currently queued.","resourceLocation":null}

    2. GET request:
    https://wiki-copy/rest/scroll-versions/1.0/async-tasks/0A656907016363F941F9775C308A600F?since=1526382751

    Response with ERROR:

    {"id":"0A656907016363F941F9775C308A600F","clusterNo":-1,"startTimestamp":1526390669836,"completionTimestamp":1526390671054,"started":true,"cancelled":false,"hasFailed":true,"finished":true,"failureMessage":{"severity":"Error","message":"OneFilePerPage=false not supported for XLIFF translation provider","stackTrace":"java.lang.RuntimeException: OneFilePerPage=false not supported for XLIFF translation provider\n\tat com.k15t.scroll.platform.model.translation.provider.file.xliff.XliffTranslationFileProvider.createTranslationFileForMultiplePages(XliffTranslationFileProvider.java:73)\n\tat com.k15t.scroll.platform.model.translation.provider.file.AbstractTranslationFileProvider.startTranslation(AbstractTranslationFileProvider.java:171)\n\tat com.k15t.scroll.platform.ui.translation.StartTranslationTask.doExecute(StartTranslationTask.java:31)\n\tat com.k15t.scroll.platform.ui.translation.StartTranslationTask.doExecute(StartTranslationTask.java:17)\n\tat com.k15t.scroll.platform.model.task.AbstractTransactionalTask$1.doInTransaction(AbstractTransactionalTask.java:31)\n\tat com.atlassian.sal.core.transaction.HostContextTransactionTemplate$1.doInTransaction(HostContextTransactionTemplate.java:21)\n\tat com.atlassian.sal.spring.component.SpringHostContextAccessor$1.doInTransaction(SpringHostContextAccessor.java:71)\n\tat org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133)\n\tat com.atlassian.sal.spring.component.SpringHostContextAccessor.doInTransaction(SpringHostContextAccessor.java:68)\n\tat com.atlassian.confluence.spring.transaction.interceptor.ConfluenceSpringHostContextAccessor.access$001(ConfluenceSpringHostContextAccessor.java:21)\n\tat com.atlassian.confluence.spring.transaction.interceptor.ConfluenceSpringHostContextAccessor.lambda$doInTransaction$3(ConfluenceSpringHostContextAccessor.java:72)\n\tat com.atlassian.confluence.impl.vcache.VCacheRequestContextManager.doInRequestContextInternal(VCacheRequestContextManager.java:87)\n\tat com.atlassian.confluence.impl.vcache.VCacheRequestContextManager.doInRequestContext(VCacheRequestContextManager.java:71)\n\tat com.atlassian.confluence.spring.transaction.interceptor.ConfluenceSpringHostContextAccessor.doInTransaction(ConfluenceSpringHostContextAccessor.java:72)\n\tat sun.reflect.GeneratedMethodAccessor250.invoke(Unknown Source)\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n\tat java.lang.reflect.Method.invoke(Method.java:498)\n\tat com.atlassian.plugin.util.ContextClassLoaderSettingInvocationHandler.invoke(ContextClassLoaderSettingInvocationHandler.java:26)\n\tat com.sun.proxy.$Proxy311.doInTransaction(Unknown Source)\n\tat sun.reflect.GeneratedMethodAccessor250.invoke(Unknown Source)\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n\tat java.lang.reflect.Method.invoke(Method.java:498)\n\tat com.atlassian.plugin.osgi.bridge.external.HostComponentFactoryBean$DynamicServiceInvocationHandler.invoke(HostComponentFactoryBean.java:136)\n\tat com.sun.proxy.$Proxy311.doInTransaction(Unknown Source)\n\tat com.atlassian.sal.core.transaction.HostContextTransactionTemplate.execute(HostContextTransactionTemplate.java:18)\n\tat sun.reflect.GeneratedMethodAccessor5272.invoke(Unknown Source)\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n\tat java.lang.reflect.Method.invoke(Method.java:498)\n\tat org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302)\n\tat org.eclipse.gemini.blueprint.service.importer.support.internal.aop.ServiceInvoker.doInvoke(ServiceInvoker.java:56)\n\tat org.eclipse.gemini.blueprint.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.java:60)\n\tat org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)\n\tat org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133)\n\tat org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121)\n\tat org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)\n\tat org.eclipse.gemini.blueprint.service.util.internal.aop.ServiceTCCLInterceptor.invokeUnprivileged(ServiceTCCLInterceptor.java:70)\n\tat org.eclipse.gemini.blueprint.service.util.internal.aop.ServiceTCCLInterceptor.invoke(ServiceTCCLInterceptor.java:53)\n\tat org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)\n\tat org.eclipse.gemini.blueprint.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:57)\n\tat org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)\n\tat org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133)\n\tat org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121)\n\tat org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)\n\tat org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208)\n\tat com.sun.proxy.$Proxy2748.execute(Unknown Source)\n\tat com.k15t.scroll.platform.model.task.AbstractTransactionalTask.execute(AbstractTransactionalTask.java:28)\n\tat com.k15t.scroll.platform.model.task.impl.DefaultAsyncTask.call(DefaultAsyncTask.java:232)\n\tat java.util.concurrent.FutureTask.run(FutureTask.java:266)\n\tat java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)\n\tat java.util.concurrent.FutureTask.run(FutureTask.java:266)\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)\n\tat java.lang.Thread.run(Thread.java:745)\n"},"progress":0,"message":"Collecting pages for new translation in 'Datamart (ru)' (DMRU).","resourceLocation":null}
    0
    Comment actions Permalink
  • Avatar
    Roman Serazhiev (Edited )

    Hi Pavel.

    Looks like the documentation page is outdated, I have fixed this. With the POST request you have to provide this body parameter: oneFilePerPage. If you are using xliff provider, you have to state oneFilePerPage with value true. By default this parameter is optional and its default value is false.

    Simply do the same POST request with additional parameter oneFilePerPage to be true and the GET request shouldn't throw the exception.

    In the response of the GET request look for <fileId>, which can be used to generate a link to download the Translation ZIP:

    Let me know if this helped.

    Cheers,
    Roman.

    0
    Comment actions Permalink
  • Avatar
    Pavel (Edited )

    Now request works correctly.
    Thank!

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk