How To Fix API cannot connect to Online Web Hosting












0














I'm making a car rental application on Android Studio, initially I entered the API on localhost XAMPP and this work. After I move to hosting online, and I point to the hosting address. Can't connect.



public class client {
private static final String URL="https://ssrentalmobil.000webhostapp.com/rental-api/";
private static final String URL_IMAGE="https://ssrentalmobil.000webhostapp.com/rental-api/upload/avatars/";
private static final String URL_IMG="https://ssrentalmobil.000webhostapp.com/rental-api/upload/";


public static request getApi() {
//Builder Retrofit
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(URL)
.addConverterFactory(GsonConverterFactory.create())
.build();

return retrofit.create(request.class);
}

public static String getBaseUrlImage() {
return URL_IMAGE;
}

public static String getBaseImg() {
return URL_IMG;
}


}










share|improve this question







New contributor




Fajar Syairillah is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • What error you get
    – maytham-ɯɐɥʇʎɐɯ
    Dec 27 '18 at 15:37










  • moving you api code is not enough you need to move the database also outside your local environment, and checking if you hosting service approve the ip addresses, any firewall rules, it's not an android problem if it works locally it"s server side issue
    – Oussema Aroua
    Dec 27 '18 at 15:45










  • As mentioned by others, there are multiple variables that can contribute to the problem. For starters, you need to supply the error log as there might be a response code hidden which is received from the server. That response code will indicate as to if the communication is successful or not.
    – Nero
    Dec 27 '18 at 15:55










  • I have moved the database and set it up in hosting online. When I run in the browser it work. But when im run this android app it's don't work. There is no connection
    – Fajar Syairillah
    Dec 27 '18 at 16:34
















0














I'm making a car rental application on Android Studio, initially I entered the API on localhost XAMPP and this work. After I move to hosting online, and I point to the hosting address. Can't connect.



public class client {
private static final String URL="https://ssrentalmobil.000webhostapp.com/rental-api/";
private static final String URL_IMAGE="https://ssrentalmobil.000webhostapp.com/rental-api/upload/avatars/";
private static final String URL_IMG="https://ssrentalmobil.000webhostapp.com/rental-api/upload/";


public static request getApi() {
//Builder Retrofit
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(URL)
.addConverterFactory(GsonConverterFactory.create())
.build();

return retrofit.create(request.class);
}

public static String getBaseUrlImage() {
return URL_IMAGE;
}

public static String getBaseImg() {
return URL_IMG;
}


}










share|improve this question







New contributor




Fajar Syairillah is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • What error you get
    – maytham-ɯɐɥʇʎɐɯ
    Dec 27 '18 at 15:37










  • moving you api code is not enough you need to move the database also outside your local environment, and checking if you hosting service approve the ip addresses, any firewall rules, it's not an android problem if it works locally it"s server side issue
    – Oussema Aroua
    Dec 27 '18 at 15:45










  • As mentioned by others, there are multiple variables that can contribute to the problem. For starters, you need to supply the error log as there might be a response code hidden which is received from the server. That response code will indicate as to if the communication is successful or not.
    – Nero
    Dec 27 '18 at 15:55










  • I have moved the database and set it up in hosting online. When I run in the browser it work. But when im run this android app it's don't work. There is no connection
    – Fajar Syairillah
    Dec 27 '18 at 16:34














0












0








0







I'm making a car rental application on Android Studio, initially I entered the API on localhost XAMPP and this work. After I move to hosting online, and I point to the hosting address. Can't connect.



public class client {
private static final String URL="https://ssrentalmobil.000webhostapp.com/rental-api/";
private static final String URL_IMAGE="https://ssrentalmobil.000webhostapp.com/rental-api/upload/avatars/";
private static final String URL_IMG="https://ssrentalmobil.000webhostapp.com/rental-api/upload/";


public static request getApi() {
//Builder Retrofit
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(URL)
.addConverterFactory(GsonConverterFactory.create())
.build();

return retrofit.create(request.class);
}

public static String getBaseUrlImage() {
return URL_IMAGE;
}

public static String getBaseImg() {
return URL_IMG;
}


}










share|improve this question







New contributor




Fajar Syairillah is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











I'm making a car rental application on Android Studio, initially I entered the API on localhost XAMPP and this work. After I move to hosting online, and I point to the hosting address. Can't connect.



public class client {
private static final String URL="https://ssrentalmobil.000webhostapp.com/rental-api/";
private static final String URL_IMAGE="https://ssrentalmobil.000webhostapp.com/rental-api/upload/avatars/";
private static final String URL_IMG="https://ssrentalmobil.000webhostapp.com/rental-api/upload/";


public static request getApi() {
//Builder Retrofit
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(URL)
.addConverterFactory(GsonConverterFactory.create())
.build();

return retrofit.create(request.class);
}

public static String getBaseUrlImage() {
return URL_IMAGE;
}

public static String getBaseImg() {
return URL_IMG;
}


}







android api android-studio web-hosting






share|improve this question







New contributor




Fajar Syairillah is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




Fajar Syairillah is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




Fajar Syairillah is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Dec 27 '18 at 15:33









Fajar Syairillah

12




12




New contributor




Fajar Syairillah is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Fajar Syairillah is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Fajar Syairillah is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • What error you get
    – maytham-ɯɐɥʇʎɐɯ
    Dec 27 '18 at 15:37










  • moving you api code is not enough you need to move the database also outside your local environment, and checking if you hosting service approve the ip addresses, any firewall rules, it's not an android problem if it works locally it"s server side issue
    – Oussema Aroua
    Dec 27 '18 at 15:45










  • As mentioned by others, there are multiple variables that can contribute to the problem. For starters, you need to supply the error log as there might be a response code hidden which is received from the server. That response code will indicate as to if the communication is successful or not.
    – Nero
    Dec 27 '18 at 15:55










  • I have moved the database and set it up in hosting online. When I run in the browser it work. But when im run this android app it's don't work. There is no connection
    – Fajar Syairillah
    Dec 27 '18 at 16:34


















  • What error you get
    – maytham-ɯɐɥʇʎɐɯ
    Dec 27 '18 at 15:37










  • moving you api code is not enough you need to move the database also outside your local environment, and checking if you hosting service approve the ip addresses, any firewall rules, it's not an android problem if it works locally it"s server side issue
    – Oussema Aroua
    Dec 27 '18 at 15:45










  • As mentioned by others, there are multiple variables that can contribute to the problem. For starters, you need to supply the error log as there might be a response code hidden which is received from the server. That response code will indicate as to if the communication is successful or not.
    – Nero
    Dec 27 '18 at 15:55










  • I have moved the database and set it up in hosting online. When I run in the browser it work. But when im run this android app it's don't work. There is no connection
    – Fajar Syairillah
    Dec 27 '18 at 16:34
















What error you get
– maytham-ɯɐɥʇʎɐɯ
Dec 27 '18 at 15:37




What error you get
– maytham-ɯɐɥʇʎɐɯ
Dec 27 '18 at 15:37












moving you api code is not enough you need to move the database also outside your local environment, and checking if you hosting service approve the ip addresses, any firewall rules, it's not an android problem if it works locally it"s server side issue
– Oussema Aroua
Dec 27 '18 at 15:45




moving you api code is not enough you need to move the database also outside your local environment, and checking if you hosting service approve the ip addresses, any firewall rules, it's not an android problem if it works locally it"s server side issue
– Oussema Aroua
Dec 27 '18 at 15:45












As mentioned by others, there are multiple variables that can contribute to the problem. For starters, you need to supply the error log as there might be a response code hidden which is received from the server. That response code will indicate as to if the communication is successful or not.
– Nero
Dec 27 '18 at 15:55




As mentioned by others, there are multiple variables that can contribute to the problem. For starters, you need to supply the error log as there might be a response code hidden which is received from the server. That response code will indicate as to if the communication is successful or not.
– Nero
Dec 27 '18 at 15:55












I have moved the database and set it up in hosting online. When I run in the browser it work. But when im run this android app it's don't work. There is no connection
– Fajar Syairillah
Dec 27 '18 at 16:34




I have moved the database and set it up in hosting online. When I run in the browser it work. But when im run this android app it's don't work. There is no connection
– Fajar Syairillah
Dec 27 '18 at 16:34












1 Answer
1






active

oldest

votes


















0














Make sure you've added the permission.



If not, add this line



<uses-permission android:name="android.permission.INTERNET" /> 


in your AndroidManifest.xml



Check the doc for more details



If it didn't help, try adding a logging interceptor and check the log






share|improve this answer























  • I have done permission Internet in manifest
    – Fajar Syairillah
    Dec 27 '18 at 16:28










  • Please check the update
    – Anees
    Dec 27 '18 at 16:32











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});






Fajar Syairillah is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53947393%2fhow-to-fix-api-cannot-connect-to-online-web-hosting%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Make sure you've added the permission.



If not, add this line



<uses-permission android:name="android.permission.INTERNET" /> 


in your AndroidManifest.xml



Check the doc for more details



If it didn't help, try adding a logging interceptor and check the log






share|improve this answer























  • I have done permission Internet in manifest
    – Fajar Syairillah
    Dec 27 '18 at 16:28










  • Please check the update
    – Anees
    Dec 27 '18 at 16:32
















0














Make sure you've added the permission.



If not, add this line



<uses-permission android:name="android.permission.INTERNET" /> 


in your AndroidManifest.xml



Check the doc for more details



If it didn't help, try adding a logging interceptor and check the log






share|improve this answer























  • I have done permission Internet in manifest
    – Fajar Syairillah
    Dec 27 '18 at 16:28










  • Please check the update
    – Anees
    Dec 27 '18 at 16:32














0












0








0






Make sure you've added the permission.



If not, add this line



<uses-permission android:name="android.permission.INTERNET" /> 


in your AndroidManifest.xml



Check the doc for more details



If it didn't help, try adding a logging interceptor and check the log






share|improve this answer














Make sure you've added the permission.



If not, add this line



<uses-permission android:name="android.permission.INTERNET" /> 


in your AndroidManifest.xml



Check the doc for more details



If it didn't help, try adding a logging interceptor and check the log







share|improve this answer














share|improve this answer



share|improve this answer








edited Dec 27 '18 at 16:32

























answered Dec 27 '18 at 15:56









Anees

4,23841045




4,23841045












  • I have done permission Internet in manifest
    – Fajar Syairillah
    Dec 27 '18 at 16:28










  • Please check the update
    – Anees
    Dec 27 '18 at 16:32


















  • I have done permission Internet in manifest
    – Fajar Syairillah
    Dec 27 '18 at 16:28










  • Please check the update
    – Anees
    Dec 27 '18 at 16:32
















I have done permission Internet in manifest
– Fajar Syairillah
Dec 27 '18 at 16:28




I have done permission Internet in manifest
– Fajar Syairillah
Dec 27 '18 at 16:28












Please check the update
– Anees
Dec 27 '18 at 16:32




Please check the update
– Anees
Dec 27 '18 at 16:32










Fajar Syairillah is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















Fajar Syairillah is a new contributor. Be nice, and check out our Code of Conduct.













Fajar Syairillah is a new contributor. Be nice, and check out our Code of Conduct.












Fajar Syairillah is a new contributor. Be nice, and check out our Code of Conduct.
















Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53947393%2fhow-to-fix-api-cannot-connect-to-online-web-hosting%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Monofisismo

Angular Downloading a file using contenturl with Basic Authentication

Olmecas