I am trying to upload a project template to a Groupshare 2017 SR1 server using the Groupshare Kit and I receive error 400 in the response. Groupshare Kit version is the currently released one obtained through NuGets.
My code looks like this:
Dim ServerURI As New System.Uri("http://myserver" & "/Suborg")
Dim GSClient = AwaitGroupShareClient.AuthenticateClient("Test", "Test_01", ServerURI, GroupShareClient.AllScopes)
Dim TemplateFileName As String = "Path to the project template goes here"
Try
'Reading template file into byte array
Dim FS As FileStream
FS = New FileStream(TemplateFileName, FileMode.Open, FileAccess.Read, FileShare.Read)
Dim Buffer(FS.Length) As Byte
If FS.Length > 0 Then
FS.Read(Buffer, 0, FS.Length - 1)
FS.Close()
Dim UploadTemplate = Await GSClient.Project.UploadProjectTemplate(templateId:="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", projectTemplate:=Buffer, templateName:="TESTTPL")
Buffer = Nothing
FS = Nothing
Else
MsgBox("Template file was empty")
End If
Catch ex As Exception
MsgBox(ex.ToString)
End Try
If you look at the line in bold that is where the request to POST the new template is issued and where I receive a 400 error back.
If I step through the groupshare kit code that is executed, I can see this is my request that is sent to Groupshare:
{Method: POST, RequestUri: 'winserv2016/.../upload', Version: 1.1, Content: System.Net.Http.MultipartFormDataContent, Headers:
"{\"Message\":\"Failed to load project template from 'C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Temp\\\\tmp1ADF.tmp': \\r\\nThere is an error in XML document (87, 18).\\r\\n'\\u0000' is an unexpected token. The expected token is '>'. Line 87, position 18.\"}"
If I look at my template file, Line 87, position 18 is the closing > of the root element:
Can you tell me, why the Groupshare Kit returns this error?
Many thanks,
Tom
Generated Image Alt-Text
[edited by: RWS Community AI at 4:24 AM (GMT 0) on 15 Nov 2024]