unable to call external payment gateway api via dotnet code

Ram Chenna 101 Reputation points
2022-01-21T07:24:11.663+00:00

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

thanks

ram

Internet Information Services
C#
C#
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
    2022-01-21T10:08:20.017+00:00

    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)

    https://www.sharepointdiary.com/2014/10/how-to-add-host-file-entry-using-powershell.html#:~:text=How%20to%20Add%20HOST%20file%20Entry%20using%20PowerShell%3F,the%20contents%20of%20the%20Hosts%20file%20%24File%20


  2. AgaveJoe 26,186 Reputation points
    2022-01-21T12:57:16.577+00:00

    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?