unable to call external payment gateway api via dotnet code

Ram Chenna 101 Reputation points

Hi All

Please provide your inputs, suggestions.

I have an application deployed in IIS and calling an external api service which is working via POSTMAN and as well as from browser.

But when the same API is called via code and executed via IIS through front end application, it gives an error as below

System.net.Http.HttpRequestException: No such host is known

System.net.Sockets.SocketException (11001): No such host is known

At System.net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, Cancellationtoken cancellationtoken)

O/S: Windows Server 2019

IIS: IIS 10.0.xx

Front End app: React

Web services: REST APIs using Dotnet Core 3.1 hosted on IIS 

Database: SQL Server 2017

POSTMAN: works

Browser: works

But when the code executed via IIS it gives us the above error. 

Any help



Internet Information Services
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,204 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Ken Tucker 5,846 Reputation points

    Sounds like a DNS issue on the server the web site is hosted on. Maybe add a host file entry for the url you are trying to hit on the web server(s)


  2. AgaveJoe 26,186 Reputation points

    Can you clarify? You installed PostMan and Chrome on the server and both applications can access the api URL from the server? If so, then there is a problem with the code. Most likely the URL is incorrect. What is the URL the application is trying to access?