Project title:
vb.net sub to connect to API using certificate. Yes that simple
Posted by:
External project from PeoplePerHour
Started:
20-Dec-2022 11:26 GMT
Description:
I have a very simple project. I only need a good response back from an API. The code is working in postman however I am getting a 502 error in vb.net using WebClient and HttpWebRequest. I will provide the .pfx certificate and postman curl as well as my code. At a loss on how to correct this as it looks fine to me in the trace file. I had this code working at one time but after I migrated from visual studio enterprise to visual studio professional I am no longer able to connect. curl --location --request POST 'https://card-sandbox.api.fiservapps.com/cs/oauth2/v1/token?scope=/cs/api' \ --header 'Content-Type: application/x-www-form-urlencoded' \ --header 'x-fapi-financial-id: 12345678' \ --header 'Authorization: Basic S212SGs1bERZaUIxUlB1cVNVODVZOFRVR25rWTE1OUE6TUMxZDdSQWRoUkdLQ2JTTw==' \ --data-urlencode 'grant_type=client_credentials' Code Private Sub TestConnection() Dim PrivateKeyPath As String = "C:\Backup\JHACPSCardClient Core Dir New Pin Pad FISERV - Copy\bin\Debug\SANDBOXSITE_API.pfx" Dim CertificatePassword As String = "Zk7XD3FG5ycW2suc" Dim cert As New X509Certificate2(PrivateKeyPath, CertificatePassword, X509KeyStorageFlags.Exportable) Dim handler As New WebRequestHandler() handler.ClientCertificates.Add(cert) Dim client As New HttpClient(handler) ' client.DefaultRequestHeaders.Add("Content-Type", "application/x-www-form-urlencoded") client.DefaultRequestHeaders.Accept.Add(New Headers.MediaTypeWithQualityHeaderValue("application/x-www-form-urlencoded")) client.DefaultRequestHeaders.Add("x-fapi-financial-id", "12345678") client.DefaultRequestHeaders.Add("Authorization", "Basic S212SGs1bERZaUIxUlB1cVNVODVZOFRVR25rWTE1OUE6TUMxZDdSQWRoUkdLQ2JTTw==") Dim formData As New FormUrlEncodedContent(New Dictionary(Of String, String) From {{"grant_type", "client_credentials"}}) Dim response As HttpResponseMessage = client.PostAsync(https://card-sandbox.api.fiservapps.com/cs/oauth2/v1/token?scope=/cs/api, formData).Result If response.IsSuccessStatusCode Then Dim responseContent As String = response.Content.ReadAsStringAsync().Result ' Do something with the response Else ' Handle error End If End Sub
Project ID:
3300764
Project category:
Project budget:
Project
Started
AGIT SUDIANTO
Category : Public Relations, System Admin Budget : $10 - $30 USD
01 Apr 2023 16:04 GMT
Brand Manager for Medical Content Writing
Category : Artificial Intelligence, Content Writing, Medical Writing, Technical Writing Budget : $250 - $750 USD
01 Apr 2023 16:04 GMT
Logo for after school program
Category : Graphic Design, Illustration, Logo Design, Photoshop, T Shirts Budget : $10 - $30 USD
01 Apr 2023 16:04 GMT
I need a soldering specialist -- 2
Category : Electrical Engineering, Electronics, Engineering, Soldering Budget : £250 - £750 GBP
01 Apr 2023 16:04 GMT
Simple copy typing work
Category : Copy Typing, Data Entry, Data Processing, Excel, Word Budget : ₹1500 - ₹12500 INR
01 Apr 2023 16:03 GMT
Japanese to Chinese translation (hentai game translation/long term)
Category : Japanese Translator, Simplified Chinese Translator, Translation Budget : $750 - $1500 USD
01 Apr 2023 16:03 GMT
Logo Brand
Category : 3D Design, Graphic Design, Illustration, Logo Design, Photoshop Budget : $15 - $25 USD
01 Apr 2023 16:02 GMT
Bakerved Ayurvedic Cookies
Category : HTML, Web Design Budget : ₹12500 - ₹37500 INR
01 Apr 2023 16:01 GMT
Sewing pattern designer
Category : Fashion Design, Pattern Making Budget : $10 - $30 USD
01 Apr 2023 16:00 GMT
graphic designer needed
Category : Brochure Design, Corporate Identity, Covers & Packaging, Graphic Design, Logo Design Budget : $15 - $25 USD
01 Apr 2023 16:00 GMT
Add 2 Images to Shopify Page
Category : CSS, HTML, Shopify, Shopify Templates, Web Design Budget : $10 - $30 USD
01 Apr 2023 15:59 GMT
Excellent fiction story needed.
Category : Creative Writing, Fiction, Ghostwriting, Romance Writing Budget : $150 - $400 USD
01 Apr 2023 15:56 GMT
Small Azure project for 12$ only.
Category : Azure, Microsoft Azure Budget : $2 - $8 CAD
01 Apr 2023 15:54 GMT
BUSCO DESARROLLADOR WEB CON EXPERIENCIA COMPROBABLE EN DISEÑO FRONT-END Y BACK-END
Category : SEO, Shopify, Web Hosting, Web Design, WordPress Budget : $2 - $8 AUD
01 Apr 2023 15:54 GMT
Looking a flutter developer to customer my application source code
Category : Flutter, IPhone, JavaScript, Mobile App Development Budget : ₹1500 - ₹12500 INR
01 Apr 2023 15:54 GMT
Browse All Projects