Q:

Send String Query With Retrofit

Because my previous question was not answered, I decided to ask my question another way.
I'm trying to send string query to server with retrofit. but the response is null. How to send String query with retrofit?
When i try the exact URL in browser everything works fine. but the URL that retrofit sends not work. i have to write "search" query Manual. 
This is the interface:
 @FormUrlEncoded
    @POST("get_near_shop_cat.php")
    Observable<NearShopLocationModel> getNearShopBySearch(@Field("lat") Double lat, @Field("lng") Double lng, @Field("search") String search);

This is my calls:
private Observable<NearShopLocationModel> getObservableNearShopBySerach(Double lat,Double lng,String search){
    return NetworkClient.getRetrofit().create(NetworkInterface.class)
            .getNearShopBySearch(lat,lng,search)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread());
}

private DisposableObserver<NearShopLocationModel> getObserverNearShop(){
    return new DisposableObserver<NearShopLocationModel>() {
        @Override
        public void onNext(NearShopLocationModel nearShopLocationModel) {
            smvi.getNearShop(nearShopLocationModel);
        }

        @Override
        public void onError(Throwable e) {
            String a=e.getMessage();
        }

        @Override
        public void onComplete() {
            smvi.isAllDataLoad(true);
        }
    };
}

And this is the php code from server:
<?php 

//Importing the database connection 
require_once('DBconnect.php');

$lat = $_GET['lat'];    
$lng = $_GET['lng'];    
$search = $_GET["search"];  

    //SQL query to fetch data of a range 
    $sql = "SELECT id,title,imageURL1,comment,categoryName,lat,lng, ( 3959 * acos( cos( radians(" . $lat . ") ) * cos( radians( lat ) ) * cos( radians( lng ) - radians(" . $lng . ") ) + sin( radians(" . $lat . ") ) * sin( radians( lat ) ) ) ) 
    AS distance FROM shop WHERE title LIKE CONCAT('%',$search, '%') || categoryName LIKE CONCAT('%',$search, '%') HAVING distance < 5";

    //Getting result 
    $res = mysqli_query($con,$sql); 

    //Adding results to an array 
    $results = array(); 

    while($row = mysqli_fetch_array($res)){
            array_push($results, array(
            "id"=>$row['id'],
            "title"=>$row['title'],
            "imageURL1"=>$row['imageURL1'],
            "comment"=>$row['comment'],
            "categoryName"=>$row['categoryName'],
            "lat"=>$row['lat'],
            "lng"=>$row['lng']
            )
            );

    }
    //Displaying the array in json format 
    echo json_encode(array("results"=>$results));

This is the log from okhttp:
    D/OkHttp: --> POST https://admanandroid.ir/bavand/get_near_shop_cat.php
    Content-Type: application/x-www-form-urlencoded
D/OkHttp: Content-Length: 85
    lat=35.5092706&lng=46.1725443&search=%DA%A9%D8%A7%D9%85%D9%BE%DB%8C%D9%88%D8%AA%D8%B1
D/OkHttp: --> END POST (85-byte body)

and this is the exact URL that works fine in browser:
https://admanandroid.ir/bavand/get_near_shop_cat.php?lat=35.5092706&lng=46.1725443&search=%22%DA%A9%D8%A7%D9%85%D9%BE%DB%8C%D9%88%D8%AA%D8%B1%22

I try with GET but the same result. the response is empty. i think the problem is the 'search' query. if you look at the browser URL the search have %22% in start and end of the string. but the retrofit URL does not have it

A:

EDIT:  

if you look at the browser URL the search have %22% in start and end of the string. but the retrofit URL does not have it

%22 is for qoutation mark, it means your api is eexpecting your string query to be enclosed in qoutation marks. Enclose it in qoutation marks while calling retrofit function:
            .getNearShopBySearch(lat,lng,"\"" + search "\"")

Your browser sends A GET request when you use that url but in your code, you re trying to send a POST request. Change your function to GET and pass in parameters as queries.
@GET("get_near_shop_cat.php")
Observable<NearShopLocationModel> getNearShopBySearch(@Query("lat") Double lat, @Query("lng") Double lng, @Query("search") String search);

