GroupShare API Projects and File Upload

Hi,

I'm running into an issue using the GroupShare 2017 API.

So basically if I create a project using the GroupShare UI and then use the REST API to upload a file I'm not able to open that project in Studio. I get the "Failed to open server project error".

Maybe I'm just using the API the wrong way but the requirement is to push several files to an existing project and then retrieve the translation later by using the webhook service.

Repro steps are:

- Create project using GS UI

- Upload file using the method displayed here

https://community.sdl.com/developers-more/developers/language-developers/w/wiki/3451/how-to-upload-files-to-an-existing-gs-project

- Go to studio and try to open the project from the server

Repro steps 2:

- Create project using GS UI

- Open project from studio (it works here)

- Upload file using the method displayed here

https://community.sdl.com/developers-more/developers/language-developers/w/wiki/3451/how-to-upload-files-to-an-existing-gs-project

- Go to studio (now it complains that project was unpublished from the server)

Any help is greatly appreciated.

Thanks

Parents
  • Hi Joao, 

    Mid-project updates are not supported by GroupShare. This means that after a project was created (either from Studio or GroupShare) it is not possible to add any more files to the project. 

    Basically what happens in your case, after a project was published you call the api/projectserver/v2/projects/{project id}/files/upload endpoint again. This will add the file to the project and it will trigger additional batch tasks (convert to translateable, do initial assignments, etc). However since there was already a project published with the same ID - the result will be undefined. That's why you get the error in Studio. 

    There's a flag in the Rest API files upload endpoint to signal that you're "just" uploading files but do not want to trigger the project creation process. This will allow you to call the upload endpoint as many times as you wish to add files to a "future" project. 

    The steps to do this is as follows: 

    - do a POST request to /api/projectserver/v2/projects with project information JSON payload to create the project "skeleton". This call will return a project unique identifier. 

    - do one or more POST requests to /api/projectserver/v2/projects/{project id from first step}/files/upload&create={true|false} to upload files for the project. Adjuest the create flag in the query string to signal that you're finished with uploading files and project creation can be scheduled. By default this flag is set to true (i.e. after the first upload request project creation will be triggered). 

    Let us know if you need any more clarification or help!

  • Hi Zoltan,

    Thanks for this, it makes sense now why it behaves that way.

    Since I was experimenting with Studio it felt like it was possible, I would:

    1. Add additional files to the same project

    2. Run prepare

    3. Check in the file

    4. Confirm it's in GroupShare

    So for an integration with an external service we'll have to do the steps you mentioned and create a new project every time?

    If I'm understanding this correctly, then we will have lots of projects with on translation only, which is not the way the translation team have the projects set up.

    Is this a limitation of the 2017 API or will this change in the 2019 or 2020 versions?

    Thanks again!

  • Yes, Studio supports adding a new file to a project. When a file is added to Studio it runs the prepare tasks. If the project was a GS project then GS will pick up the changes, via the syncronization package. 

    However GS never supported adding files to a project after the project was published, via GS APIs. 

    If your requirements state that you need to add files to an already started project then you won't be able to do that reliable using GS Rest API. Again, this was never supported in GS via it's APIs and AFAIK there are no immediate plans to support this. 

    However, it is possible to add files to an existing GS project from Studio. I'm not sure if Studio API have support for it though. 

  • Hi Zoltan,

    Thanks again for the clarifications.

    I'm testing out the steps you outlined above but I'm running into an issue, steps here:

    1. POST to

    /api/projectserver/v2/projects with Body

    {"Name":"TEST01","OrganizationId":"xxx"}

    2. Retrieve the ID

    3. POST to

    api/projectserver/v2/projects/xxx/files/upload

    Body as form-data with a TXT file attached

    but here I get 500 Internal Server Error

    {
        "Message": "An error has occurred."
    }

    I was expecting at this point to have the project created in GroupShare, the error message is not that helpful so I'm not sure where to get more information about what's happening.

Reply
  • Hi Zoltan,

    Thanks again for the clarifications.

    I'm testing out the steps you outlined above but I'm running into an issue, steps here:

    1. POST to

    /api/projectserver/v2/projects with Body

    {"Name":"TEST01","OrganizationId":"xxx"}

    2. Retrieve the ID

    3. POST to

    api/projectserver/v2/projects/xxx/files/upload

    Body as form-data with a TXT file attached

    but here I get 500 Internal Server Error

    {
        "Message": "An error has occurred."
    }

    I was expecting at this point to have the project created in GroupShare, the error message is not that helpful so I'm not sure where to get more information about what's happening.

Children
  • Hi Joao, 

    Sorry for not replying earlier to you on this. 


    If an error occurs an there's no detail returned then it was probably an unexpected exception that we log it. So, to see what has gone wrong you would need to inspect the log files on Groupshare server, stored under C:\ProgramData\SDL\Service\Logs. Look into Sdl.Application and Sdl.ExecutionService log files. 

    I was able to create a simple project (with a single file) using Postman like this: 

    1. POST request to create the project "skeleton"

    POST /api/projectserver/v2/projects
    Content-Type: application/json
    Authorization: <a valid token>

    {
    "Name": "Postman test",
    "DueDate": "2019-12-01T13:45:30Z",
    "OrganizationId": "30915437-7aff-4389-a490-3a56b7f7a3f0",
    "ProjectTemplateId": "0132b663-5853-48cb-b236-da5e9a2c5d9b"
    }

    Here you need to make sure that the OrganizationId and ProjectTemplateId values are valid, i.e. both the organization and project template with the specified id exists and the user has access to it. 

    The response is HTTP 201, a JSON value of "734fff3d-579f-4797-8556-af7d112720e2" (the created project id)

    2. Second request to upload a file and trigger project creation: 

    POST /api/projectserver/v2/projects/734fff3d-579f-4797-8556-af7d112720e2/files/upload?create=true Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW

    The response is HTTP 200. After some time the project shows up.