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
Oracle Database Installation on Ubuntu Linux
Category : Database Administration, Linux, Oracle, VMware Budget : €2 - €6 EUR
07-May-2024 10:04 GMT
Complex Online Form Filling Assistance
Category : Copy Typing, Data Entry, PDF, Word Budget : $8 - $15 USD
07-May-2024 10:04 GMT
Article be punished on high quality websites to get the whatsapp green tick
Category : Article Rewriting, Copywriting Budget : ₹1500 - ₹12500 INR
07-May-2024 10:04 GMT
Asian International Cuisine Kindle Books
Category : Book Writing, EBooks, Ghostwriting, Graphic Design Budget : ₹12500 - ₹37500 INR
07-May-2024 10:03 GMT
WordPress Automated Quoting Plugin Enhancements
Category : MySQL, PHP, Software Testing, Web Design, WordPress Budget : $250 - $750 USD
07-May-2024 10:03 GMT
Find and fix CLS and INP issues on two sites
Category : CSS, HTML5, Web Design Budget : €8 - €30 EUR
07-May-2024 10:02 GMT
Arabic Translation for Wash Care Design
Category : Adobe InDesign, Arabic Translator, Brochure Design, Graphic Design, Illustration Budget : ₹600 - ₹1500 INR
07-May-2024 10:01 GMT
Digital Wallet Advantages
Category : Article Rewriting, Article Writing, Content Writing, Ghostwriting, Research Writing Budget : £10 - £20 GBP
07-May-2024 10:00 GMT
Monochrome Abstract Logo Creation
Category : Graphic Design, Illustration, Logo Design Budget : ₹600 - ₹1500 INR
07-May-2024 10:00 GMT
C[sharp] developer for Windows Applications
Category : C#, Programming, Windows Desktop Budget : ₹180 - ₹1800 INR
07-May-2024 10:00 GMT
YouTube Video Editor Needed
Category : After Effects, Video Editing, Video Production, Video Services, Videography Budget : ₹100 - ₹400 INR
07-May-2024 09:59 GMT
Laravel, Cpanel & Nginx Setup
Category : Apache, Laravel, Linux, Nginx, PHP Budget : £10 - £100 GBP
07-May-2024 09:59 GMT
Women's Clothing Shopify Store Marketing
Category : Google Adwords, Internet Marketing, Link Building, Marketing, SEO Budget : $8 - $15 USD
07-May-2024 09:58 GMT
Japanese photovoltaic solar panel survey
Category : Advertising, Chemical Engineering, Marketing, Project Management, Project Scheduling Budget : $1500 - $3000 USD
07-May-2024 09:57 GMT
Virtual Camera Code Adaptation for Windows
Category : C, Programming, C#, C++, JavaScript, Windows Desktop Budget : $30 - $250 USD
07-May-2024 09:56 GMT
Browse All Projects