How to get data from an Web API hosted in iis with ionic

Hi guys,

I have been trying to make web API requests to my ASP.Net core 2.2 web API that is hosted in IIS. I can get back results when I use ‘example.com:50056/api/Vehicle/GetCarpaint’ from my browser. However, I get ‘Host could not be resolved: java.net.UnknownHostException: Unable to resolve host “drsmashservices.com”: No address associated with hostname’ when I make the same request from my app. My PC and phone are both on the same network. After testing with different domains, :

Is there something from my url, am I not following the correct syntax? here’s other peices of my code:

In my AndroidManifest.xml
“xml”: “<uses-permission android:name=“android.permission.INTERNET” />”

this.nativeHttp.setHeader(‘localhost’,‘content-type’, ‘application/json’);

  await this.nativeHttp.post('http://192.168.8.X/api/Vehicle/GetCarpaint', JSON.stringify(payload), {})
  .then( res => { 
    let parsed = JSON.parse(res.data)
    return parsed.result })
  .catch(err => { console.log(err) })

I get the same error, have you been able to solve this?

Hi,

I was able to solve it by:

  • removing the Host name of the site (when you add site)
  • add an inbound rule at the system’s firewall settings
  • add this line at the bottom of the hosts file in the C:\Windows\System32\drivers\etc
    ‘127.0.0.1 example.com

Then everything shall work according.

1 Like