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
Scanned PDF typed into Spreadsheet
Category : Copy Typing, Data Entry, Data Processing, Excel, Transcription Budget : $10 - $30 CAD
29-Mar-2024 11:04 GMT
Detailed Kitchen 3D Model Design
Category : 3D Animation, 3D Design, 3D Modelling, 3D Rendering, 3ds Max Budget : £174 - £175 GBP
29-Mar-2024 11:03 GMT
Urgent: Cartoon-Style Comic Artist Needed
Category : Arts & Crafts, Caricature & Cartoons, Concept Design, Illustration Budget : €2 - €6 EUR
29-Mar-2024 11:02 GMT
CSS Repair on WordPress Layout
Category : CSS, HTML, PHP, Web Design, WordPress Budget : £10 - £20 GBP
29-Mar-2024 11:02 GMT
Product Details Web Data Scraping
Category : Data Mining, Excel, Python, Web Scraping Budget : ₹750 - ₹1250 INR
29-Mar-2024 11:00 GMT
Event Bartender Needed for 50 Guests
Category : Copy Typing, Customer Support, Data Entry, Virtual Assistant, Web Search Budget : $30 - $250 SGD
29-Mar-2024 11:00 GMT
Virtual Assistant for Document Transcription
Category : Copy Typing, Data Entry, Excel, Transcription, Virtual Assistant Budget : $15 - $25 USD
29-Mar-2024 11:00 GMT
Advanced Excel Tabulation
Category : Data Entry, Data Processing, Excel, Microsoft Office, Visual Basic Budget : €30 - €250 EUR
29-Mar-2024 11:00 GMT
Dokończenie strony - PHP/ CodeIgniter 3
Category : Codeigniter, CSS, MySQL, PHP, Web Design Budget : $1000 - $5000 USD
29-Mar-2024 10:58 GMT
customization a wordpress payment gateway plugin
Category : CSS, HTML, PHP, Web Design, WordPress Budget : $30 - $250 USD
29-Mar-2024 10:57 GMT
Pet Tracker: Bluetooth-Based Subscription App
Category : Android, IPad, IPhone, Mobile App Development, Objective C Budget : $30 - $250 AUD
29-Mar-2024 10:57 GMT
Survey Form Validation JavaScript Script
Category : CSS, HTML, JavaScript, JQuery / Prototype, PHP Budget : €250 - €750 EUR
29-Mar-2024 10:55 GMT
Opensearch Implementation For Detailed PDF Mining
Category : Elasticsearch, Generative AI, JavaScript, PHP Budget : $10 - $30 USD
29-Mar-2024 10:55 GMT
I need two customised audio backdrops samples
29-Mar-2024 10:41 GMT
Player statistics website
29-Mar-2024 10:41 GMT
Browse All Projects