androidhttpclient

Retrofit 2.0-beta-2 is adding literal quotes to MultiPart values

自作多情 提交于 2019-11-28 11:53:49
Went to upgrade to Retrofit 2.0 and running into this weird problem. I have a method to log a user in public interface ApiInterface { @Multipart @POST("user/login/") Call<SessionToken> userLogin(@Part("username") String username, @Part("password") String password); } When I look at the key value POST params on the server side they print like this username : "brian" password : "password" The same method using retrofit 1.9 the K:V pairs look like username : brian password : password It's adding literal quotes to the POST variables If I use any other rest client the variables print like the

Send information from android application to a Web Service and back

谁说我不能喝 提交于 2019-11-28 09:33:48
问题 Let's say I need to create an android app which will, on the click of a button, send a number from a textbox to a web service. This service will send back a string saying "your number was ... " and a list of employees taken from a database sent back as XML I do not have a physical access to the code of the web service but I know that it has a "getData" method which takes an int and returns the string. It also has a "GetEmployees" method which takes nothing and returns the XML mentionned above

Why does android get the wrong ssl certificate? (two domains, one server)

旧城冷巷雨未停 提交于 2019-11-28 06:29:05
I have two domains: foo.net and bar.com . They both have SSL certificates, and they work well in all desktop and mobile browsers. They are hosted on the same server configured with nginx. However, when I make a request to a domain from within a native android app, it somehow gets the certificate from the wrong domain! This results in an IO Exception: request = new HttpPost("https://foo.net/api/v1/baz"); request.setHeader("Authorization", "user:pass"); response = httpClient.execute(request); ... javax.net.ssl.SSLException: hostname in certificate didn't match: <foo.net> != <bar.com> OR <bar.com

Multipart/form-data construction with android

笑着哭i 提交于 2019-11-28 01:13:50
问题 I am trying to make an HttpPost with multiPart/form-data via my android app. I have a postman test that is working with my api and the preview of that request in postman, looks like this: POST /api/0.1/content/upload HTTP/1.1 Host: 54.221.194.167 X-AUTHORIZATION: 166e649911ff424eb14446cf398bd7d6 Cache-Control: no-cache Postman-Token: 2412eba9-f72d-6f3b-b124-6070b5b26644 ----WebKitFormBoundaryE19zNvXGzXaLvS5C Content-Disposition: form-data; name="file01" {"mime_type":"image/jpeg","title":"IMG

A good approach to do multipart file upload in Android

你说的曾经没有我的故事 提交于 2019-11-27 23:07:08
问题 I am working on a piece of code to do multipart form data POST request, which in my case is just to upload an image to server with parameters. Here's what I have now: I have a button to trigger the multipart request, in the button OnClickListener, I have this code to spin a new thread: new Thread(new Runnable(){ @Override public void run() { String photoUri = getPhotoUri(); String url = getEndPointUrl(); try { NewPostRequest.postFile(url, photoUri, <Other Params...>); } catch (Exception e) {

The import org.apache.http.client cannot be resolved error when I update sdk to M

天大地大妈咪最大 提交于 2019-11-27 22:53:11
I am getting following errors when I import project into eclipse. I have updated my sdk to M. import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.HttpVersion; import org.apache.http.NameValuePair; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.HttpClient; import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.params.BasicHttpParams; import

Retrofit 2.0-beta-2 is adding literal quotes to MultiPart values

时光毁灭记忆、已成空白 提交于 2019-11-27 06:34:41
问题 Went to upgrade to Retrofit 2.0 and running into this weird problem. I have a method to log a user in public interface ApiInterface { @Multipart @POST("user/login/") Call<SessionToken> userLogin(@Part("username") String username, @Part("password") String password); } When I look at the key value POST params on the server side they print like this username : "brian" password : "password" The same method using retrofit 1.9 the K:V pairs look like username : brian password : password It's adding

Why does android get the wrong ssl certificate? (two domains, one server)

半世苍凉 提交于 2019-11-27 01:08:28
问题 I have two domains: foo.net and bar.com . They both have SSL certificates, and they work well in all desktop and mobile browsers. They are hosted on the same server configured with nginx. However, when I make a request to a domain from within a native android app, it somehow gets the certificate from the wrong domain! This results in an IO Exception: request = new HttpPost("https://foo.net/api/v1/baz"); request.setHeader("Authorization", "user:pass"); response = httpClient.execute(request); .

The import org.apache.http.client cannot be resolved error when I update sdk to M

风格不统一 提交于 2019-11-26 21:12:54
问题 I am getting following errors when I import project into eclipse. I have updated my sdk to M. import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.HttpVersion; import org.apache.http.NameValuePair; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.HttpClient; import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; import

Getting NoSuchFieldError INSTANCE org/apache/http/message/BasicHeaderValueParser

我们两清 提交于 2019-11-26 20:17:19
I'm working on an app on Android. I'm using httpcore 4.3.3. I get this when I try to use ContentType.parse(string) java.lang.NoSuchFieldError: No static field INSTANCE of type Lorg/apache/http/message/BasicHeaderValueParser; in class Lorg/apache/http/message/BasicHeaderValueParser; or its superclasses (declaration of 'org.apache.http.message.BasicHeaderValueParser' appears in /system/framework/ext.jar) I've done some googling and I understand why I'm getting the error, but I'm unsure how to fix it. From what I've read, it seems that ContentType tries to make use of the BasicHeaderValueParser