Hello,
We are testing GroupShare's Project Server capabilities in different automation/integration scenarios. As a business requirement, we need a mechanism to send data from our project management system to GS REST API using Linux command line. Usually we use curl for such tasks and it would be optimal if we managed to send project creation and file upload requests with curl as well. Following the instructions in How to create a GroupShare project using Swagger UI and How to upload files to an existing GS Project , I can create a project using Swagger UI and upload files with Postman without issues, but would like to know how to perform the same actions with curl.
I can successfully create a project with a following curl request (real IDs replaced with dummy values)
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: Bearer <token>' -d '{"Name":"GSAPITest1","OrganizationId":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx","Description":"","ProjectTemplateId":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx","DueDate":"2024-11-30T09:49:09.186Z","ReferenceProjects":[{"ReferenceProjectId":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx","IsLocked":true,"ReferenceProjectName":"string"}],"SuppressEmail":true,"IsSecure":false}' 'groupsharedev.sdlproducts.com/.../projects'
and get a project ID as a response, but when trying to upload a file (.zip archive), there is no response. For example, if I run the following curl command
curl -v -X POST --header 'Accept: application/zip' --header 'Authorization: Bearer <token>' -F '=@"/path/to/the/Test.zip"' 'groupsharedev.sdlproducts.com/.../upload'
I get following results when using the --verbose option:
Note: Unnecessary use of -X or --request, POST is already inferred.
* Host groupsharedev.sdlproducts.com:443 was resolved.
* IPv6: (none)
* IPv4: 3.127.110.122, 3.77.248.104
* Trying 3.127.110.122:443...
* Connected to groupsharedev.sdlproducts.com (3.127.110.122) port 443
* ALPN: curl offers h2,http/1.1
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* CAfile: /etc/ssl/certs/ca-certificates.crt
* CApath: /etc/ssl/certs
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
* TLSv1.3 (IN), TLS handshake, Finished (20):
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / TLS_AES_128_GCM_SHA256 / X25519 / RSASSA-PSS
* ALPN: server accepted h2
* Server certificate:
* subject: CN=*.sdlproducts.com
* start date: Sep 22 00:00:00 2024 GMT
* expire date: Oct 21 23:59:59 2025 GMT
* subjectAltName: host "groupsharedev.sdlproducts.com" matched cert's "*.sdlproducts.com"
* issuer: C=US; O=Amazon; CN=Amazon RSA 2048 M02
* SSL certificate verify ok.
* Certificate level 0: Public key type RSA (2048/112 Bits/secBits), signed using sha256WithRSAEncryption
* Certificate level 1: Public key type RSA (2048/112 Bits/secBits), signed using sha256WithRSAEncryption
* Certificate level 2: Public key type RSA (2048/112 Bits/secBits), signed using sha256WithRSAEncryption
* using HTTP/2
* [HTTP/2] [1] OPENED stream for groupsharedev.sdlproducts.com/.../upload
* [HTTP/2] [1] [:method: POST]
* [HTTP/2] [1] [:scheme: https]
* [HTTP/2] [1] [:authority: groupsharedev.sdlproducts.com]
* [HTTP/2] [1] [:path: /api/projectserver/v2/projects/<projectId>/files/upload]
* [HTTP/2] [1] [user-agent: curl/8.5.0]
* [HTTP/2] [1] [accept: application/zip]
* [HTTP/2] [1] [authorization: Bearer <token>]
* [HTTP/2] [1] [content-length: 906]
* [HTTP/2] [1] [content-type: multipart/form-data; boundary=------------------------wgOoYrS3CQl5VHrRbpOuLW]
> POST /api/projectserver/v2/projects/<projectId>/files/upload HTTP/2
> Host: groupsharedev.sdlproducts.com
> User-Agent: curl/8.5.0
> Accept: application/zip
> Authorization: Bearer <token>
> Content-Length: 906
> Content-Type: multipart/form-data; boundary=------------------------wgOoYrS3CQl5VHrRbpOuLW
>
* We are completely uploaded and fine
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
< HTTP/2 200
< date: Wed, 30 Oct 2024 13:31:01 GMT
< content-length: 0
< server: Microsoft-IIS/10.0
< x-powered-by: ARR/3.0
< x-frame-options: SAMEORIGIN
< permissions-policy: clipboard-read=self, clipboard-write=self
< x-content-type-options: nosniff
< x-permitted-cross-domain-policies: none
< cross-origin-embedder-policy: require-corp
< cross-origin-opener-policy: same-origin
< cross-origin-resource-policy: same-origin
< referrer-policy: no-referrer
<
* Connection #0 to host groupsharedev.sdlproducts.com left intact
The response appears to me as okay, but the project does not appear when querying the https://groupsharedev.sdlproducts.com/api/projectserver/v2/projects endpoint. I've tried sending the same request with same information as parameters (create: true, reference:false and relativePath pointing to the actual URL-encoded file path), based on the documentation in Swagger UI, although relativePath is not required with .zip archives and reference is false and create is true by default.
If I repeat an upload request, the GS server responds with {"Message":"Adding Test.zip would result in duplicate files having the same name."}, so the file(s) are uploaded but project is not created. Am I just missing something essential which triggers project creation? Is there a way to get listing of projects which are registered for project creation, i.e. created by sending appropriate POST request to https://groupsharedev.sdlproducts.com/api/projectserver/v2/projects endpoint but which are not properly created by adding files?
I'd be grateful if someone could point out flaws in my curl requests or even point me to the right direction - or even suggest a solution.
Best,
Mikko