1. Pierre Couvreur
  2. SnapDevelop
  3. Friday, 26 April 2019 09:41 AM UTC

Hello,

Using PB 2019 build 2002, I followed the tuto to create and test a Web API, then adapted it to work with an Oracle database.

Everything is working fine except when I try to change from localhost to another host. Actually, it does  work with cURL or Postman (as long as I uncheck the 'Use System Proxy option') but it doesn't with PB RestClient or from a browser. I guess it is related with the enterprise proxy but I don't know how to work around it from within PB…

Any help appreciated !

Pierre

 Application startup :

 

This works : curl http://xxx.xxx.xxx.xxx:5000/dnfapi/agent/retrieve

This doesn't work : l_rest.Retrieve(dw_3, "http://xxx.xxx.xxx.xxx:5000/dnfapi/agent/retrieve")

From Postman, it does work :

 

 

From Firefox, it doesn't work :

 

Roland Smith Accepted Answer Pending Moderation
  1. Friday, 26 April 2019 12:50 PM UTC
  2. SnapDevelop
  3. # 1

Since this is in Beta, you should report it as a bug so that it can be fixed.

https://www.appeon.com/standardsupport/search

 

Comment
There are no comments made yet.
Adrian Hernandez Accepted Answer Pending Moderation
  1. Friday, 26 April 2019 13:54 PM UTC
  2. SnapDevelop
  3. # 2

Hi Pierre!

Could you share us a little bit more detail on the steps you followed to deploy the API to the server?

The issue might be related to the port, since web explorers (and clients) won't allow by default custom ports on any host different from localhost. (Testing tools like Postman don't have this restriction).

Regards!!

Comment
There are no comments made yet.
Pierre Couvreur Accepted Answer Pending Moderation
  1. Friday, 26 April 2019 14:09 PM UTC
  2. SnapDevelop
  3. # 3

Hi Adrian,

Actually the API is not yet trully deployed on a server, I still run it on my developper PC and I try to make it accessible thru my PC's IP adress instead of localhost. Let's say it was my first step before moving the API to a server.

I just modified launchSettings.json like this and ran the API straight from the SnapDevelop IDE :

 "WebAPI1": {
      "commandName": "Project",
      "launchBrowser": false,
      "launchUrl": "api/sample/load",
      "applicationUrl": "http://*:5000;https://*:5001",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }

 

For Roland : I just tried from within PB2017R3 with the same result.

Thank you,

Pierre

 

Comment
  1. Roland Smith
  2. Friday, 26 April 2019 14:52 PM UTC
You can add a 'fake' URL to your Hosts file to pretend to be accessing it from a server when it will actually be on your local machine. It is located in C:\Windows\System32\drivers\etc. It is a text file without an extension. Run Notepad as administrator and paste the path into the file open box.
  1. Helpful
  1. Pierre Couvreur
  2. Monday, 6 May 2019 09:27 AM UTC
Hi Roland,

I just tried your suggestion to add an entry in the host file and it works : I can reach the webAPI from another station as long as the host is updated on that station !

However It is not very clear to me, I thought the host file was just a mean to give a readable alias to an IP adress but it looks like it does more than this...

Pierre

  1. Helpful
There are no comments made yet.
Adrian Hernandez Accepted Answer Pending Moderation
  1. Friday, 26 April 2019 15:04 PM UTC
  2. SnapDevelop
  3. # 4

Hi Pierre.

By default, the API is listening only on localhost, try changing the 'CreateHostBuilder' method in Program.cs so it looks like this:

public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
            WebHost.CreateDefaultBuilder(args)
                .UseStartup()
                .UseUrls("http://*:5000;https://*:5001");

 

Hope this solves your issue

Regards!

Comment
There are no comments made yet.
Pierre Couvreur Accepted Answer Pending Moderation
  1. Friday, 26 April 2019 15:20 PM UTC
  2. SnapDevelop
  3. # 5

Adrian,

I tried your suggestion without result, I think that changing the 'CreateHostBuilder' method in Program.cs has the same effect as modifying options in launchSettings.json like I already did.

In both case, the API is listening to all IP adresses but PB RestClient (or a browser) doesn't succeed to "reach" it.

I'll give Roland suggestion to modify host file next week.

Thank you !

Pierre

 

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.