Create An HTTP Connection | raywenderlich.com


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/10376651-android-networking-fundamentals/lessons/4

In the end of the lesson I get the error from Heroku

java.io.FileNotFoundException: https://taskie-rw.herokuapp.com/api/register

Hey there!

Are you sure youā€™re using POST and not GET? I just tested the request, and everything is working fine!

I found the problem. I missed a quote in the end and incorrect data causes HTTP 400 that interpreted as FileNotFoundException for some reason. Donā€™t know why but now it works for me.

The service doesnā€™t work for me either, I even tried it for postman. I get error 400, and when I debug I get FileNotFoundException

Hey @ricindigus!

Have you checked that your JSON string is valid? Weā€™ve had issues where people missed a quote at the end, or didnā€™t format something correctly!

Also, make sure that youā€™re using POST for register, instead of GET. I just tested out the API using Postman, and it seems to be working fine.

So url should be: ā€œhttps://taskie-rw.herokuapp.com/api/registerā€ and the JSON should look like this (if you use an online formatter):

{
	"name":"username",
	"email":"email@email.com",
	"password":"password"
}

Thanks!

1 Like

Muchas gracias ahora ya funciona!!!

1 Like

@ricindigus Please post your comment in English. Thank you!

Hi! I have a problem with the registration of an user, i got ā€œInvalid data!ā€ every time. I even tried to run your code from Final folder and I get the same errorā€¦ so i donā€™t think itā€™s an internal problem :-?

Hey @moonlime!

Have you tried using different data for the user? Given that Iā€™ve used the data in the video, it wonā€™t make sense to reuse that data because such a user is already registered. But if you try to use different data, you should be fine. Try changing the email to something unique and it should work fine!

I used your code, not your credentialsā€¦ tried different combinations of users/emails/passwordsā€¦nothing works

I just tested the API using Postman and everything works.

Have you set the appropriate flags on the HTTP connection: ā€œdoInputā€ & ā€œdoOutputā€ to true?

Did you check your JSON structure & formatting to be correct/as in the tutorial? All the escaped String literals, all the colons and commas?

This should be your JSON structure:

{
	"name":"pilips",
	"email":"example@mail.com",
	"password":"password"
}

Edit: Iā€™ll check everything with the project too, but last time I checked this it worked fine.

Edit 2: I just downloaded the final project of E4, and everything worked for me. Created an account without a problem.

Iā€™ve created a new device and run it again but on API 30, so i guess that was the problem:-? Thank you for your time tho

1 Like

filbabic

is the Base_url still valid? Currently doing the tutorial but it doesnā€™t seem to be ā€˜liveā€™ anymore as I get ā€˜Invalid Dataā€™ when trying to register in the app and when I go to the link i get:
Cannot GET /api/register

Hey @swiftlearnerlv !

The app is still running. You should be using POST for registering if Iā€™m not mistaken, as per other comments above! Also - the reason you might receive invalid data is because your JSON is not formatted correctly, so please check that too.

As for the emails not being valid etc, thatā€™s because the email is already registered and you canā€™t register with the same email twice. You should use your email or a dummy email from a temp account to register to the app.

Thanks!

1 Like

Hello, community,

Iā€™m getting the same error. I already updated to SDK 30, checked all the JSON format, used a completely personal email, and even cloned the same repo and used the FINAL folder, however, Iā€™m getting INVALID DATA.

I debugged the app and get this:

It says the response is NULL because of the URL.

Looks like the server is down.

Please, what solution can we get? I paid for this course but is useless if I can not use the endpoints your using on the tutorials.

Waiting a kindly reply