Android - Magento REST Api Cannot Respond Properly -


I want to call the Magento REST API from Android, using the code below.

  new Execution on HttpAsyncTask () "(http://myweb.com/api/rest/products"); Public Stabilized String Received (String URL) {InputStream inputStream = null; String result = ""; Try {// HttpClient HTTP Client httpclient = Create New DefaultHttpClient (); // Receive the request for the given URL HttpSpace httpResponse = httpclient.execute (New HTTP Gate (URL)); Get feedback as // inputstream inputStream = httpResponse.getEntity (). GetContent (); // Convert inputstream to string if (inputstream! = Null) result = convert inputstreamtoostring (inputstream); And the result = "did not work!"; } Hold (exception e) {log d. ("Inputstream", E.A.T.L.Klimised Message ()); } Return results; } Private String String Convert InputStreamToString (InputStream InputStream) throws IOException {BufferedReader bufferedReader = New BufferedReader (New InputStreamReader (inputStream)); String line = ""; String result = ""; While ((line = bufferedReader.readLine ()) = null) result + = line; InputStream.close (); Return result; } Private class HttpAsyncTask asyncTask and lt; String, zero, string & gt; {@Override protected string doInBackground (string ... url) {return (URL [0]); } // onPostExecute Displays the results of AsyncTask @Overreaded Protected Zero on postexec (string result) {toast. Make Text (getBaseContext (), "Received!", Toast. LNNHHLog) Show (); EtResponse.setText (results); }  

The URL is not empty, I received an answer from another sample url using the same code. But the Magento url has been given the "service temporarily unavailable" result. I do not know what's wrong with this. I have 2 questions

  1. Is it possible to call a Magento REST AP URL directly from the client

  2. Is it possible to call the Maganta Rest API without OAuth (called without iAuth).

Any Magento Android REST Api connection can help me please.

In the end, I did this by using the following code, without Oath. Anyone using the Rest API for Android can use it. To get expansions compared to the product using Oouth.

  New HTTPSink Task () Execute ("http: // myweb.com/api/rest/products"); Private class HttpAsyncTask asyncTask extended & lt; String, zero, string & gt; {@Override Safe String doInBackground (string ... url) {string host = "myweb.com"; HTTP Client Client = New DefaultHttpClient (); BasicHttpContext localContext = new BasicHttpContext (); HTTPHost targethost = new HTTPHost host (host, 443, "https"); Log D. ("Url", url [0]); HttpGet httpget = New HttpGet (URL [0]); Httpget.setHeader ("content-type", "app / json"); Httpget.setHeader ("Accept", "App / JS"); HTTP response response; Object content = null; JSONObject json = faucet; Try {feedback = client.execute (targetHost, httpget, localContext); HttpEntity unit = response.getEntity (); Content = EntityUtils.toString (unit); Json = new JSONObject (content.toString ()); Log D. ("Result", "OK:" + json.toString (1)); }}  

Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -