ENS
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
Imports VERAG_PROG_ALLGEMEIN.CC015B_TR_EXT_V4_3
|
||||
Imports Org.BouncyCastle.Ocsp
|
||||
Imports VERAG_PROG_ALLGEMEIN.CC015B_TR_EXT_V4_3
|
||||
Imports VERAG_PROG_ALLGEMEIN.ENS_CC315A
|
||||
|
||||
Public Class cHMRC_ENS
|
||||
@@ -13,6 +14,7 @@ Public Class cHMRC_ENS
|
||||
|
||||
|
||||
|
||||
|
||||
Shared Function helloWorldENS(ByVal response As String) As Boolean
|
||||
|
||||
|
||||
@@ -29,18 +31,16 @@ Public Class cHMRC_ENS
|
||||
' HTTP-Client initialisieren
|
||||
Dim http As New Chilkat.Http
|
||||
|
||||
' HMRC OAuth2 Access Token (muss vorher abgerufen werden)
|
||||
Dim accessToken As String = "YOUR_ACCESS_TOKEN"
|
||||
|
||||
' Falls das Token fehlt, Hinweis ausgeben
|
||||
If String.IsNullOrEmpty(accessToken) Then
|
||||
If String.IsNullOrEmpty(TOKEN.token_BEARER_TOKEN) Then
|
||||
Console.WriteLine("Fehler: Kein OAuth2-Token gefunden!")
|
||||
Return False
|
||||
End If
|
||||
|
||||
' Setze die benötigten Header
|
||||
http.SetRequestHeader("Authorization", "Bearer " & accessToken)
|
||||
http.SetRequestHeader("Accept", "application/vnd.hmrc.1.0+json")
|
||||
http.SetRequestHeader("Accept", "application/vnd.hmrc.1.0+xml")
|
||||
http.SetRequestHeader("Content-Type", "application/xml; charset=UTF-8")
|
||||
http.SetRequestHeader("Authorization", "Bearer " & TOKEN.token_BEARER_TOKEN)
|
||||
|
||||
' API-Endpunkt für User-Restricted Hello API
|
||||
Dim url As String = "https://test-api.service.hmrc.gov.uk/hello/application"
|
||||
@@ -52,8 +52,10 @@ Public Class cHMRC_ENS
|
||||
' Fehlerbehandlung
|
||||
If (http.LastMethodSuccess <> True) Then
|
||||
Console.WriteLine("Fehler: " & http.LastErrorText)
|
||||
MsgBox("Fehler: " & http.LastErrorText)
|
||||
Else
|
||||
Console.WriteLine("Antwort von HMRC API: " & response)
|
||||
MsgBox("Antwort von HMRC API: " & response)
|
||||
End If
|
||||
Return True
|
||||
End If
|
||||
@@ -73,7 +75,7 @@ Public Class cHMRC_ENS
|
||||
Else
|
||||
url = "api.service.hmrc.gov.uk"
|
||||
End If
|
||||
|
||||
MsgBox(url)
|
||||
VERAG_PROG_ALLGEMEIN.cChilkat_Helper.UnlockCilkat()
|
||||
|
||||
'-------------------------------------------------------
|
||||
@@ -118,7 +120,7 @@ Public Class cHMRC_ENS
|
||||
req.LoadBodyFromString(ENS_CC315A.Serialize, "utf-8")
|
||||
|
||||
' Füge benötigte Header hinzu
|
||||
req.AddHeader("Accept", "application/x-www-form-urlencoded") '"application/vnd.hmrc.1.0+xml")
|
||||
req.AddHeader("Accept", "application/vnd.hmrc.1.0+xml") '"application/vnd.hmrc.1.0+xml")
|
||||
req.AddHeader("Content-Type", "application/xml; charset=UTF-8") '"application/xml")
|
||||
req.AddHeader("Authorization", "Bearer " & TOKEN.token_BEARER_TOKEN)
|
||||
' req.AddHeader("Gov-Client-Connection-Method", "WEB_APP_VIA_SERVER")
|
||||
|
||||
Reference in New Issue
Block a user