GET request not working in android app - android

I am sending a GET request from my app, and on the phone I do not get the response, and it does not appear on my feed, however, if I copy paste the url on the browser, I can see the text that is supposed to appear.
For that, I installed BURP Proxy Suite to see what am I sending and receiving to and from the server, and below is the response that showed in Burp.
GET /?feed=rss2&tag1=mytagone&tag2=mytagtwo HTTP/1.1
Host: myhost.com
Connection: close
User-Agent: Apache-HttpClient/UNAVAILABLE (java 1.4)
Any ideas?

first open the connection as OPEN and run it and if wont works again run the >code change the USER-AGENT

Related

HTTP calls in same wireless network glassfish

I have an endpoint which is available at following url: http://localhost:18080/app/register (via POST request). I want to make calls to this endpoint from my Android device, which is in the same Wireless network (the IP for the laptop running the server is 172.16.xx.xx). When I am making my request from the laptop (server) to this endpoint: http://172.16.xx.xx:18080/app/register, everything works fine.
When I am making the POST request from my Android device to the same endpoint, I get back a 400 Bad Request with message "The request sent by the client was syntactically incorrect". I checked the URL, I checked the JSON, I made the request with exactly the same body via curl from my laptop and everything looks fine.
Has someone experience this problem before? I don't know where I should start from with my investigation. I am deploying my application on Glassfish 4.1.2

Ionic $http request get not working with error data null status -1

I use Ionic and Cordova framework for developing a mobile app, I've got the issue that can not use http get to request some url. For $http.get to some url that works fine, but some others not work and it response error like as
I/Web Console( 9179): {"data":null,"status":-1,"config":{"method":"GET","transformRequest":[null],"transformResponse":[n ull],"url":"http://someexmaple.com/","headers":{"Accept":"application/json, text/plain, */*"},"withCredentials":true}," statusText":""}
This issue only happens when I test on real mobile device and using adb debugging tool. But I tested on Browser and Genymotion virtual devices, both of them worked well for all url request.
So I've know idea with this response error. I think may be my device got problem.
Finally I've resolved my problem. I use inspect tool in Chrome, and move to network tab for watching the network packet, I see when I access to the url of site, it redirect me to another server port (instead of 80, it redirect to 443), I've noticed this because the 'Remote Address field' is the same address of url server, but port was changed. So I changed my $http.get request url from port 80 into port 443. And then it works, so I guess that when $http.get to the url but it didn't redirect to another port to get data, so it just response the null.

Bad request when connecting to ASP.NET page on IIS from android application

I have a ASP.NET website deployed to IIS with a couple of ashx that returns JSONs to be consumed by an Android application.
I have implemented an authentication logic using Basic Authentication.
The problem: When accessed from Android, the server response is a 400 Bad request. The httperr log file says "400 - Hostname -".
It works when I try it out on localhost from Android emulator
It works when accessing the ashx file on the server from a browser
It works when replicating the call in Fiddler
(If I use Fiddler with the Android Emulator, the Response will be -1 (and looking in Fiddler at the raw data sent, it seems to loose the host from the url) - but this is another issue so don't dwell on that, i just thought I would mention it...)
Turns out my problem (and solution) was the same as in this thread:
HTTP POST request with authorization on android

Yahoo messenger API - error when open a long-lived connection for Comet-style notification

I'm trying to get Yahoo messenger notifications (comet style) to work on my Android app but I got a problem:
I have all the oauth tokens + IM cookie, I make the call to notify server but it responds with
403 Bad IM cookie or URI credential
The IM cookie which is sent is correct because it is the same as the one I got from POST /session.
The call:
POST to:http://rproxy2.messenger.yahooapis.com/v1/pushchannel/user_id?sid=T3qRkifs3BiGXCW4LOSoThi3lG2HvWNagr.mGA--&rand=-1131022177&count=10&seq=1&format=json&IM=2x5A0IOr9Js_8er8BgSYUCB9fjB.d20FbKds7NdJdkzWK4u2A92k5dMrM72OetLz9.q70NQCwZpAqafQ5.XM-|QTvOT1rY3ukBC8o4Z0zeRg--&oauth_consumer_key=dj0yJmk9cFNKb2NKbTdINEtFJmQ9WVdrOVpHMW1aVXhKTjJNbWNHbzlNamcyTnpNMU1UWXkmcz1jb25zdW1lcnNlY3JldCZ4PWJh&oauth_nonce=939bc51c9a594c7cbf903643bc10f7d1&oauth_signature_method=PLAINTEXT&oauth_timestamp=1328108171163&oauth_token=A%3DosG_yqL.hxped9sV4ZMVD2A5vugclvEOSKIw85DOg17vQa8N1jQK6UcGqeLGLXKFalrxnYA_iA_ArmhbN6oJ_CEINGwiq7MWsVjO_vQT5bwhmcBMwBLByhusduuH2BFJw1Zd2w_uDj5fEUVMK9bMDzg.fYEpdm1uK.OgwyYLPCwdkzW0w6ujPpaFAea7gwmsSBYHECzjXm8wduoe1Sw3rpJH4z9PGIe8Hkt3wrbyJpW9BuiU4g6OyE1f8nhzHVkcG_70KQiIR_oV3tP8_l4SCsbbHMvSzlyZjK1V6gJp0Q94fAcfuIWQ1Vd.iD.UZPEyzdzYK.k5Q6pE4H3At8czcXFOpmOL5eUwfbeQEtXePCL1b2v9oY4BxtH_dCUVTMhzQsV.YpKZV.ZRZzK8ThveL5gfGuqYcBZLHwVilQnQWo477XwT10GbvWUzJ2EH4v5m9q.sGMViSIKWjbE2O6YfwhYXAgQMA3d8wQLL7IoY4QC0.IR4T8M_KnZVlKoi_EiED8VuK9h7h3emBZeXoM15rqGk2..HUJQEuIe1d0YbTPEGKdM.fbCcT7_Y0Szzw3abf9b1Xjzm8VkNSKL.LXAmy8c9PyNatUT_hKFmzmWMd1RRYfd8rF7i6i7Ec_cVv06QhwCQyKlEsCQh7UChUe9JykUmiA6JOm4JOpsbTQWS1Iec35zrltc4YwouUlMx.y6JbzB_VYL9jkzeuu&oauth_version=1.0&oauth_signature=2cd720831677df11508571218aed6c36c9cf2b51%26e57b0e111092b000a43b4ae9c928178fd5da4b9f
connection: keep-alive
cookie: IM=2x5A0IOr9Js_8er8BgSYUCB9fjB.d20FbKds7NdJdkzWK4u2A92k5dMrM72OetLz9.q70NQCwZpAqafQ5.XM-|QTvOT1rY3ukBC8o4Z0zeRg--
User-Agent: Dalvik/1.2.0 (Linux; U; Android 2.2; sdk Build/FRF91)
Host: rproxy2.messenger.yahooapis.com
Content-Type: application/x-www-form-urlencoded
Content-Length: 0
The server responds with:
HTTP/1.1 403 bad IM cookie or URI credentials
Connection: close
I followed all the instrunctions from docs, not sure how can make it to work.
Thanks.
Your HTTP POST is empty (Content-Length: 0), the docs state:
Note: even though all inputs are optional, the server
still expects an empty POST body (JSON: "{}")
so, change your Content-Type to "application/json;charset=utf-8" and include
{}
as the body of the HTTP POST.
Long lived connections need to be GET calls; see "Notification Management (Comet-Style Push) API", here.

Disable gzip content-encoding in android simulator

I was trying to read the HTTP messages between the browser in the Android simulator and other third party web-servers using tcpdump. However, since the browser can accept gzip content-encoding, I can't see the HTML content as plain-text in the tcpdump output. Is there a way to change the configs of the browser so that it doesn't send that Accept-Encoding: gzip header line?
This post implies if you remove the
Accept-Encoding
header, you'll get raw data back... you should be able to write a custom WebView that never sends that header. Hope that works!
http://forgetmenotes.blogspot.com/2009/05/how-to-disable-gzip-compression-in.html

Categories

Resources