import com.google.gson.Gson;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.impl.client.DefaultHttpClient;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.conn.ClientConnectionManager;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.entity.StringEntity;
/**
*
* @author Ewrei
*///Ошибка
class ErrorObj
{
long code;
String message;
}
//Отправка телефона
class pojo1
{
int id;
public void setId(int p)
{
id = p;
}
//generate setter and getters
}
public class PovtornayOtpravka {
public static HttpClient verifiedClient(HttpClient base) {
try {
SSLContext ctx = SSLContext.getInstance("SSL");
X509TrustManager tm = new X509TrustManager() {
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return null;
}
@Override
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {}
@Override
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {}
};
ctx.init(null, new TrustManager[] { tm }, null);
SSLSocketFactory ssf = new SSLSocketFactory(ctx, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
ClientConnectionManager mgr = base.getConnectionManager();
SchemeRegistry registry = mgr.getSchemeRegistry();
registry.register(new Scheme("https", 443, ssf));
return new DefaultHttpClient(mgr, base.getParams());
} catch (Exception ex) {
ex.printStackTrace();
return null;
}
}
public static void main(String[] args) throws UnsupportedEncodingException, IOException {
pojo1 poj = new pojo1();
poj.setId(159184727);
Gson gson2 = new Gson();
StringEntity postingString = new StringEntity(gson2.toJson(poj));
String url = "https://protaxi-brest.hivelogin.ru:443/api/client/mobile/1.0/registration/resubmit&id=" + poj.id;
HttpClient client = new DefaultHttpClient();
client = verifiedClient(client);
HttpGet post = new HttpGet(url);
HttpResponse response = client.execute(post);
//final GitPolz polz = gson.fromJson(response.getEntity().(), GitPolz.class);
System.out.println("Response Code : "
+ response.getStatusLine().getStatusCode());
//String httpResponse = EntityUtils.toString(response.getEntity());
}
}
Ответ
String url = "https://protaxi-brest.hivelogin.ru:443/api/client/mobile/1.0/registration/resubmit&id=" + poj.id;
Вы некорректно передаёте параметр.
Строка параметров должна отделяться от пути запроса вопросительным знаком:
http://example.org/path?param=value¶m2=value2
Попробуйте так:
String url = "https://protaxi-brest.hivelogin.ru:443/api/client/mobile/1.0/registration/resubmit?id=" + poj.id;
Комментариев нет:
Отправить комментарий