J_D
J_D

Reputation: 429

Windows Phone WEB API Post via HttpClient Returning 404 Error

In my windows phone application I have a WinRT component that references a Portable Class Library (PCL), which contains code to do a POST to remote WEB API address via HttpClient.

The HTTP client is also sending Multipart Form Data Content.

The Windows Phone app has the Internet (Client & Server) capability enabled in the app manifest.

When I run this code calling a HTTPS URI from either a physical phone or the phone emulator I get a 404 error, however the request works when I call the same WEB API via HTTP.

I am pretty sure it is not a problem with the WEB API side of things as I have Unit/Integration Tests in the solution that call the API via both HTTP and HTTPS and they work as expected.

Am I missing something on the windows phone side? Any ideas why I would get a 404?

Upvotes: 2

Views: 503

Answers (1)

Kevin Gosse
Kevin Gosse

Reputation: 39047

On Windows Phone, you get a 404 error when trying to make a SSL (HTTPS) request with an untrusted certificate. Most likely, you're using a self-signed certificate.

For your tests, you can manually install the certificate on the phone (there's many ways, but the most practical is to upload the certificate on a server then point the web browser to the .cer file). But when publishing your application, you'll probably have to switch to a "real" trusted certificate (or ditch SSL).

Upvotes: 3

Related Questions