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
Post a Comment