diff --git a/VERAG_PROG_ALLGEMEIN/Schnittstellen/Digicast/cDigicustAPI.vb b/VERAG_PROG_ALLGEMEIN/Schnittstellen/Digicast/cDigicustAPI.vb index 2f7469ff..1a5ca24b 100644 --- a/VERAG_PROG_ALLGEMEIN/Schnittstellen/Digicast/cDigicustAPI.vb +++ b/VERAG_PROG_ALLGEMEIN/Schnittstellen/Digicast/cDigicustAPI.vb @@ -439,6 +439,12 @@ Public Class cDigicustAPI rest.VerboseLogging = True + + rest.ClearAllHeaders() + rest.ClearAllParts() + rest.PartSelector = "" + + Dim counter As Integer = 1 Dim jsonFileArray = New Chilkat.JsonArray() @@ -485,24 +491,25 @@ Public Class cDigicustAPI rest.SetMultipartBodyString(dig.reference) counter += 1 - ' createUserinput(rest, counter, dig) - + createUserinput(rest, counter, dig) + rest.PartSelector = "0" rest.AddHeader("Content-Type", "multipart/form-data") rest.AddHeader("Authorization", "Bearer " & token) rest.AddHeader("Expect", "100-continue") + + Debug.WriteLine(rest) + 'Debuging 'rest.DebugMode = True rest.IdleTimeoutMs = 60000 rest.SendReqMultipart("POST", "/upload/api/" & settings.customerId & "/" & settings.projectId & "/new") - rest.PartSelector = "0" - rest.ClearAllHeaders() - rest.ClearAllParts() - rest.PartSelector = "" + + Dim responseStatusCode = rest.ReadResponseHeader() If (responseStatusCode < 0) Then @@ -513,13 +520,18 @@ Public Class cDigicustAPI i = i + 1 Next - If rest.ResponseStatusCode <> 200 Then - MsgBox(rest.LastErrorText) - Return False - End If - End If + If Not (rest.ResponseStatusCode = 200 Or rest.ResponseStatusCode = 201) Then + MsgBox(rest.LastErrorText) + If rest.ResponseStatusCode = -1 Then + Return True + End If + Return False + End If + + + If (rest.LastMethodSuccess <> True) Then MsgBox(rest.LastErrorText) Return False @@ -558,6 +570,11 @@ Public Class cDigicustAPI dig.projectId = jsonResp.StringOf("result.projectId") dig.companyId = jsonResp.StringOf("result.customerId") + rest.ClearAllHeaders() + rest.ClearAllParts() + rest.PartSelector = "" + + Return True End Function @@ -626,26 +643,38 @@ Public Class cDigicustAPI 'zusätzliche Informationen aus dem AVISO + Dim jarr As New Chilkat.JsonArray + + jarr.AddObjectAt(-1) + Dim json As Chilkat.JsonObject = jarr.ObjectAt(jarr.Size - 1) 'beforeNormalization(fallback -> falls Daten nicht gelesen werden können, wird ergänzt) 'afterNormalization(overwrite -> werden mit mitgeschickten Infos überschrieben). + json.UpdateString("priority", "afterNormalization") + json.UpdateString("documentStatus", "finished") - Dim jsonArray As New Chilkat.JsonArray() + If sendung.consignee_name <> "" Then json.UpdateString("annotatedAggregated.consignee.name.input", sendung.consignee_name) + If sendung.consignee_address <> "" Then json.UpdateString("annotatedAggregated.consignee.address.input", sendung.consignee_address & IIf(sendung.consignee_postcode <> "", " / " & sendung.consignee_postcode, "") & IIf(sendung.consignee_city_name <> "", " " & sendung.consignee_city_name, "")) + If sendung.consignee_eori <> "" Then json.UpdateString("annotatedAggregated.consignee.EORI.input", sendung.consignee_eori) - Dim json As New Chilkat.JsonObject - If sendung.licencePlate <> "" Then - json.UpdateString("truckLicensePlate", sendung.licencePlate) + If sendung.licencePlate <> "" AndAlso sendung.lkwCountryId <> "" Then + json.UpdateString("annotatedAggregated.meansOfTransportation[0].type", "Inland") + json.UpdateString("annotatedAggregated.meansOfTransportation[0].value", "Road") + json.UpdateString("annotatedAggregated.meansOfTransportation[0].licensePlate", sendung.licencePlate) + json.UpdateString("annotatedAggregated.meansOfTransportation[0].countryCode", sendung.lkwCountryId) End If - If sendung.lkwCountryId <> "" Then - json.UpdateString("truckNationality", sendung.lkwCountryId) - End If + 'json.UpdateString("annotatedAggregated.consignee.email.input", "") + 'json.UpdateString("annotatedAggregated.consignee.contactPerson.input", "Herr Berger") + 'json.UpdateString("annotatedAggregated.consignee.VAT.input", "") rest.PartSelector = counter rest.AddHeader("Content-Disposition", "form-data; name=""documents""") - rest.SetMultipartBodyString("[{""priority"":""afterNormalization"",""annotatedAggregated"":{" & json.Emit & "}}]") + rest.SetMultipartBodyString(jarr.Emit) + + counter += 1 End Function