Bonjour la communauté,

Je fais appel à un Web Service en API Rest et mon code malgré mes recherches me renvoie toujours le message suivant :
La demande a été abandonnée: impossible de créer le canal sécurisé SSL / TLS
J'ai bien rajouté les 2 lignes suivantes :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
ServicePointManager.Expect100Continue = true
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls1
Je poste mon code, si quelqu'un d'entre vous a une idée ?

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
        Dim NewUrl As String = ""
        '
        Dim myheaders As WebHeaderCollection
        Dim postData As String = ""
        ' POST /areafse/extraireRSPs HTTP/1.1
 
 
        Dim NumeroFacture As String = ""
        '
        '
        NewUrl = "https://rcubkp........"
        '
        postData = ""
        '
        Dim request As HttpWebRequest = HttpWebRequest.Create(NewUrl)
 
        ' Set the Method property of the request to POST.
        request.Method = "POST"
        ' Create POST data and convert it to a byte array.
 
        Dim byteArray As Byte() = Encoding.UTF8.GetBytes(postData)
        ' Set the ContentType property of the WebRequest.
        request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14"
        request.Accept = "*/*"
        request.ServicePoint.Expect100Continue = True
        ServicePointManager.DefaultConnectionLimit = 9999
        ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
 
        request.ContentType = "application/json"
        request.ContentLength = byteArray.Length
        '
        myheaders = request.Headers
        myheaders.Add("Pragma", "no-cache")
 
        ' Get the request stream.
        Dim dataStream As Stream = request.GetRequestStream()
        ' Write the data to the request stream.
        dataStream.Write(byteArray, 0, byteArray.Length)
        ' Close the Stream object.
        dataStream.Close()
        ' Get the response.
        Try
            Dim response As WebResponse = request.GetResponse()
            ' Display the status.
            '
            ' Get the stream containing content returned by the server.
            dataStream = response.GetResponseStream()
            ' Open the stream using a StreamReader for easy access.
            Dim reader As New StreamReader(dataStream)
            ' Read the content.
            Dim responseFromServer As String = reader.ReadToEnd()
            ' Display the content.
            '
            If CType(response, HttpWebResponse).StatusCode = 200 Then
                Accueil.ZtCode.Text = "0"
                Accueil.ZtLibelle.Text = "La Fonction s'est déroulée avec Succès"
            Else
                Accueil.ZtCode.Text = CType(response, HttpWebResponse).StatusCode
                Accueil.ZtLibelle.Text = "Problème d'Appel du Web Service lireCPS"
            End If
            '
            Accueil.ZtDescription.Text = responseFromServer
            '
            Dim objStreamWriter As StreamWriter
            objStreamWriter = New StreamWriter(Application.StartupPath & "\Ws_response_extraireRsps.xml")
            'Write a second line of text.
            objStreamWriter.WriteLine(responseFromServer)
 
            'Close the file.
            objStreamWriter.Close()
            ' Clean up the streams.
            reader.Close()
            dataStream.Close()
            response.Close()
            '
            Return True
            '
        Catch ex As Exception
            'Accueil.ZtCode.Text = "100"
            'Accueil.ZtLibelle.Text = "Erreur ws_ExtraireRsps"
            MsgBox(ex.Message, MsgBoxStyle.Critical, "ws_ExtraireRsps")
            'Accueil.ZtDescription.Text = ex.Message
            Return False
        End Try
        '
        Return Nothing
    End Function
Merci d'avance
Jimbolion