java me - javax.microedition.pki Certificate Failed Verification -


i'm trying read in json reply google sheets api in java me midp application. i've tried following other addresses , receives content fine actual api want use sheets , returns "certificate failed verification" exception.

httpconnection c = null; inputstream = null; stringbuffer str = new stringbuffer(); try     {       c = (httpsconnection)connector.open(urlstring);      c.setrequestmethod(httpconnection.get);      c.setrequestproperty("content-type", "application/json; charset=utf-8");      c.setrequestproperty("user-agent","profile/midp-2.1 configuration/cldc-1.1");       = c.openinputstream();       int len = (int)c.getlength();      int ch;       while ( (ch = is.read() ) != -1)          {          str.append((char)ch);          }       }  catch( exception e ){ alert( ""+e ); }  return str.tostring(); 

connector.open() implicitly returns httpsconnection if url starts https should still work.

an example of https request

https://jsonplaceholder.typicode.com/posts/1 

which won't work above allows http connections

http://jsonplaceholder.typicode.com/posts/1 

which work.

google sheets requires https , not obtainable via above code. how can make request on https sheets api? thank you.

i had similar problem when implementing online highscore system 1 of our games. fetch highscores fine on phones didn't work on other phones. explanation: phones have own built-in "mime-type checker". when call (httpconnection)connector.open(urlstring) phone expects text/html response. when instead gets application/json (or other) response, phone gives own "not found" error. not sure if problem related, worth try? see if can add mime-type "application/json" in request header of httpconnection.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -