Я пытаюсь использовать Retrofit
с Restful WebService
. Кажется, все в порядке, но как-то, когда я запускаю этот код это всегда возвращает этотИспользование Retrofit с Restfull Post WebServices
Method not found. Retrofit 404 Error
Вот мой WebServices Код
public function processApi() {
$func = strtolower(trim(str_replace("/","",$_POST['request'])));
if ((int)method_exists($this,$func) > 0) {
$this->$func();
} else {
// If the method not exist with in this class, response would be "Page not found".
$this->response('Method not found',404);
}
}
private function login() {
// Cross validation if the request method is POST else it will return "Not Acceptable" status
if ($this->get_request_method() != "POST") {
// If invalid inputs "Bad Request" status message and reason
$error = array('status' => "0", "msg" => "Bad Request");
$this->response($this->json($error), 406);
}
// Input validations
if (empty($email) and empty($password)) {
$error = array('status' => "0", "msg" => "Invalid Email address or Password");
$this->response($this->json($error), 400);
}
}
public class ObjectPost {
@SerializedName("request")
String request;
@SerializedName("email")
String event_id;
public void setRequest(String request) {
this.request = request;
}
public void setEvent_id(String event_id) {
this.event_id = event_id;
}
}
А вот мой Android код запроса
public class RestClient {
public interface ClientInterface {
@POST(Config.LOGIN_URL)
void login(@Body ObjectPost mObject,
Callback<LoginBeans> callback);
}
public static ClientInterface initRestAdapter() {
OkHttpClient client = new OkHttpClient();
return (ClientInterface) new RestAdapter.Builder()
.setLogLevel(RestAdapter.LogLevel.FULL)
.setClient(new OkClient(client))
.setEndpoint(Config.SERVER_URL)
.build()
.create(ClientInterface.class);
}
}
Вы пытались с помощью браузера? Вы настроили модификацию, чтобы иметь полный уровень журнала. Что говорит журнал? –
Метод не найден. Модернизация 404 Ошибка –
Вы пытаетесь в браузере? И, пожалуйста, спросите, что ваш сторонний разработчик - это пропуск заголовка в webservice или нет. –