Skip to first unread message
Assigned to ewpa...@gmail.com by taifu...@gmail.com

Erich Mönch

unread,
Oct 28, 2017, 2:28:04 PM10/28/17
to MIT App Inventor Forum
Hi there,

I've been developing an App for some time and it's time to connect it to the Server side Webservices I developed in .NET C#. I'm running it in a Win10 with IIS Express (VS 2017 Community)

The server side webservices are fully operational as I have exhaustively tested with Postman.

The problem: i'm emulating the app and trying to connect it to my IIS at localhost and it isn't working. I'm using the IP address instead of the localhost and nothing.

I turned on the Postman's interceptor feature on the 5555 port. When I use this port, the POST call arrives (POSTMAN gets it and it's perfect). When putting the webservice IIS port, I get the return 400 Invalid Hostname. Already tried to use localhost, but doesn't work too.

Any clues on how to make the emulator speak with my webservices?

Thanks in advance!
Erich
URL.jpg
Erro 400.jpg
Postman interception.jpg

Erich Mönch

unread,
Oct 28, 2017, 7:32:06 PM10/28/17
to mitappinv...@googlegroups.com
Tried with my Android device and AI Companion. Still receiving 400 - Invalid Hostname.

The request is being sent to the IIS port (global variable: 192.168.25.8:56481) and still this problem. Postman sniffing caught the call and eveything seems to be fine.

No idea what to do...



edit: attached the print from the mobile error... anyway Postman is able to capture the request at my computer when I redirect to its port (5555).
Screenshot (28 de out de 2017 21_54_59).jpg

Erich Mönch

unread,
Oct 28, 2017, 8:59:33 PM10/28/17
to MIT App Inventor Forum
Solved!!

AI2 adds a "host" Header with name of the URL ("192.168.25.8:56481" in my case). Forcing a "host" header to "localhost:56481" made the thing work.

I think IIS Express doesn't understand the IP name..

Adding some configs to the webservice project in VS might solve it too.

Evan Patton

unread,
Oct 30, 2017, 10:04:19 AM10/30/17
to MIT App Inventor Forum
Hi Erich,

The Host header is required per HTTP/1.1 semantics (see here). Given that this works if you force the Host header to be localhost, it sounds like you need configure the IIS server to correctly handle origins other than localhost.

Regards,
Evan

Reply all
Reply to author
Forward
0 new messages