Emre Akbaki Emre Akbaki - 5 months ago 58
Android Question

Retrofit 404 not found web api

I have a web api and an application.So ı want to a Register app but i have a problem.I use the azure.
There is my registerapı (interface)

public void insertUser(
@Field("Username") String Username,
@Field("Password") String Password,
@Field("Email") String Email,
Callback<Response> callback);

and my mainactivty.java page

public class MainActivity extends AppCompatActivity {

private EditText editTextUsername;
private EditText editTextPassword;
private EditText editTextEmail;
private Button buttonRegister;
final public static String ROOT_URL = "http://bsapmusic.azurewebsites.net/api/music/register";

protected void onCreate(Bundle savedInstanceState) {
editTextUsername = (EditText) findViewById(R.id.etusername);
editTextPassword = (EditText) findViewById(R.id.etpassword);
editTextEmail = (EditText) findViewById(R.id.etmail);
buttonRegister = (Button) findViewById(R.id.btnkayit);
buttonRegister.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {

private void insertUser()
RestAdapter adapter =new RestAdapter.Builder().setEndpoint(ROOT_URL).build();
RegisterAPI api = adapter.create(RegisterAPI.class);
new Callback<Response>() {
public void success(Response result, Response response) {
BufferedReader reader = null;
String output = "";
reader=new BufferedReader(new InputStreamReader(result.getBody().in()));
catch (IOException e){

public void failure(RetrofitError error) {
Toast.makeText(MainActivity.this, error.toString(),Toast.LENGTH_LONG).show();

and ı get retrofit 404 not found .Can you help me guys ? Thx


Assuming http://bsapmusic.azurewebsites.net/api/music/register is the url to your register method in your API:

A 404 means there is no API for this url. Your baseurl is http://bsapmusic.azurewebsites.net/api/music/register After this baseurl the path inside the @post is appended. This will result in the url: http://bsapmusic.azurewebsites.net/api/music/register/application/json. The url to your register method is probably the first url. The baseurl should the url to the root url of your api, in your case this probably is: http://bsapmusic.azurewebsites.net/api/. In the @GET, @POST, @PUT you set the path to a specific api method. In your case that would be @POST("music/register"). You don't set the type of data that is sent to the API in here.