{"id":876,"date":"2012-03-07T13:37:16","date_gmt":"2012-03-07T12:37:16","guid":{"rendered":"http:\/\/www.lightsoft.se\/?page_id=876"},"modified":"2020-12-20T18:12:58","modified_gmt":"2020-12-20T17:12:58","slug":"faultreporter","status":"publish","type":"page","link":"https:\/\/www.lightsoftai.com\/?page_id=876","title":{"rendered":"FaultReporter (fixa och uppdatera f\u00f6r web)"},"content":{"rendered":"<h1><span style=\"text-decoration: underline;\">FaultReporter Rest API<\/span><\/h1>\n<p>Is a service (Open API) used to be able to report faults to, that occurs at products out at customers that you are not administrating over. Every product need to implement a send logic to send strange exceptions.<\/p>\n<p>First of you need to register a user. The email and privkey will be your private information, needed to get reports. When creating a user you will recieve a pubKey, this key is used when reporting faults from products, so email and privKey is not used from the products when reporting.<\/p>\n<h3><span style=\"text-decoration: underline;\">Unlicense vs License<\/span><\/h3>\n<p><strong>Unlicense\u00c2&nbsp; account:<\/strong><br \/>\nFaults older then <strong>15 days<\/strong> will be removed<br \/>\nMax new Faults <strong>10\/min<\/strong> will is allowed to be registered<\/p>\n<p><strong>License account: <\/strong><br \/>\nFaults older then <strong>180 days <\/strong>will be removed<br \/>\nMax new Faults <strong>100\/min<\/strong> will is allowed on a registered account<\/p>\n<p>[highlight] Buying a Licensed account is done by contacting us with a mail, include<strong> username, email, private key<\/strong>. Or buying FaultViewer at Google Play [\/highlight]<\/p>\n<p>&nbsp;<\/p>\n<h3>FaultViewer on Android<\/h3>\n<p>Want to view your faults on your Android phone?<br \/>\nThen it is possible to view your faults by downloading a free version of FaultViewer.<br \/>\nIf you want to buy a license, you will get this by buying the FaultViewer and then create a user will generate a license.<\/p>\n<p>&nbsp;<\/p>\n<h3>Restful API<\/h3>\n<h4>Register User<\/h4>\n<p>Create your user to have your personal user for all projects you will listening on faults for.<\/p>\n<p>https:\/\/www.lightsoft.se\/FaultReporter\/API\/registerUser<br \/>\nContent-Type: application\/json; charset=UTF-8<br \/>\nMandatory: name, email, privKey<br \/>\nOptional: license<br \/>\nPost: {&#8220;name&#8221;:&#8221;User Name&#8221;, &#8220;email&#8221;:&#8221;user@email.com&#8221;, &#8220;privKey&#8221;:&#8221;user private key&#8221;, &#8220;license&#8221;:&#8221;user license&#8221;}<br \/>\nResp: {&#8220;resp&#8221;:&#8221;OK&#8221;, &#8220;code&#8221;:&#8221;200&#8243;, &#8220;error&#8221;:&#8221;message if error&#8221;}<\/p>\n<p>&nbsp;<\/p>\n<h4>Get User<\/h4>\n<p>Get your user and <strong>public Key<\/strong>, that is the key you will have in all projects to report fault from. Public Key is only used in our applications when reporting to this service.<\/p>\n<p>https:\/\/www.lightsoftai.com\/FaultReporter\/API\/getUser<br \/>\nContent-Type: application\/json; charset=UTF-8<br \/>\nMandatory: email, privKey<br \/>\nPost: {&#8220;email&#8221;:&#8221;user@email.com&#8221;, &#8220;privKey&#8221;:&#8221;user private Key&#8221;}<br \/>\nResp: {&#8220;name&#8221;:&#8221;Your Name&#8221;,&#8221;pubKey&#8221;:&#8221;a4f3241-8edd-1d3147f69404&#8243;,&#8221;projects&#8221;:[{&#8220;name&#8221;:&#8221;Project1&#8243;,&#8221;totalReports&#8221;:6},{&#8220;name&#8221;:&#8221;Project2&#8243;,&#8221;totalReports&#8221;:16}]}<\/p>\n<p>&nbsp;<\/p>\n<h4>Report<\/h4>\n<p>https:\/\/www.lightsoftai.com\/FaultReporter\/API\/report<br \/>\nContent-Type: application\/json; charset=UTF-8<br \/>\nMandatory: pubKey, priority, project<br \/>\nOptional: title, data, severity<br \/>\nPost: {&#8220;pubKey&#8221;:&#8221;user pubkey&#8221;, &#8220;priority&#8221;:&#8221;1&#8243;, &#8220;project&#8221;:&#8221;projectname&#8221;, &#8220;severity&#8221;:&#8221;4&#8243;, &#8220;title&#8221;:&#8221;This is an error&#8221;, &#8220;data&#8221;:&#8221;exception&#8221;}<br \/>\nResp: {&#8220;resp&#8221;:&#8221;Created&#8221;, &#8220;code&#8221;:&#8221;201&#8243;, &#8220;error&#8221;:&#8221;message if error&#8221;}<\/p>\n<p>&nbsp;<\/p>\n<h4>Delete Report<\/h4>\n<p>https:\/\/www.lightsoftai.com\/FaultReporter\/API\/deleteReport<br \/>\nContent-Type: application\/json; charset=UTF-8<br \/>\nMandatory: privKey, email, id<br \/>\nPost: {&#8220;privKey&#8221;:&#8221;user privKey&#8221;, &#8220;email&#8221;:&#8221;user email&#8221;, &#8220;id&#8221;:&#8221;report id to remove&#8221;}<br \/>\nResp: {&#8220;resp&#8221;:&#8221;OK&#8221;, &#8220;code&#8221;:&#8221;200&#8243;, &#8220;error&#8221;:&#8221;message if error&#8221;}<\/p>\n<p>&nbsp;<\/p>\n<h4>Get Reports<\/h4>\n<p>https:\/\/www.lightsoftai.com\/FaultReporter\/API\/getReports<br \/>\nContent-Type: application\/json; charset=UTF-8<br \/>\nMandatory: privkey, project, email<br \/>\nOptional: limit (int), paging (int)<br \/>\nPost: {&#8220;privkey&#8221;:&#8221;privkey&#8221;, &#8220;project&#8221;:&#8221;name of project&#8221;, &#8220;email&#8221;:&#8221;useremail&#8221;}<br \/>\nResp: [{&#8220;id&#8221;:&#8221;35937746-8357-4a64-bd23-fs981a94d154&#8243;,&#8221;project&#8221;:&#8221;Your Project&#8221;,&#8221;title&#8221;:&#8221;Exception&#8221;,&#8221;severity&#8221;:&#8221;5&#8243;,&#8221;priority&#8221;:&#8221;3&#8243;,&#8221;data&#8221;:&#8221;&#8221;,&#8221;time&#8221;:&#8221;2012-03-12 14:28:20&#8243;},{&#8230;}]<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h3>Android code to send a Fault from an application:<\/h3>\n<p>[sourcecode language=&#8221;java&#8221;]<br \/>\npublic class FaultReporterUtil {<\/p>\n<p>private static String url_Report = &#8220;https:\/\/www.lightsoft.se\/FaultReporter\/API\/report&#8221;;<\/p>\n<p>\/**<br \/>\n* Mandatory: pubKey, priority, project, severity Optional: title, data<br \/>\n*<br \/>\n* @param message<br \/>\n*\/<br \/>\npublic static void sendFault(final String project, final String title, final int priority, final String severity, final String message) {<br \/>\ntry {<br \/>\nRunnable updateFeeds = new Runnable() {<br \/>\n@Override<br \/>\npublic void run() {<br \/>\ntry {<br \/>\nJSONObject j = new JSONObject();<br \/>\nj.put(&#8220;pubKey&#8221;, &#8220;a4f4abf3-4f75-44c3-8edd-1d3147f69404&#8221;);<br \/>\nj.put(&#8220;project&#8221;, project);<br \/>\nj.put(&#8220;priority&#8221;, String.valueOf(priority));<br \/>\nif (severity != null)<br \/>\nj.put(&#8220;severity&#8221;, String.valueOf(severity));<br \/>\nj.put(&#8220;title&#8221;, title);<br \/>\nif (message != null)<br \/>\nj.put(&#8220;data&#8221;, message);<\/p>\n<p>if (Preferences.DEBUG)<br \/>\nLog.d(Preferences.TAG_Restfull, &#8220;JSON REQUEST:&#8221; + j.toString());<\/p>\n<p>String re = JSONUtil.doPost(url_Report, j, 3);<br \/>\nif (Preferences.DEBUG)<br \/>\nLog.d(Preferences.TAG_Restfull, &#8220;RESPONSE:&#8221; + re.toString());<br \/>\n}<br \/>\ncatch (Exception e) {<br \/>\nLog.e(Preferences.TAG_Restfull, &#8220;JSON ERROR:&#8221;, e);<br \/>\n}<br \/>\n}<br \/>\n};<br \/>\nThread thread = new Thread(null, updateFeeds, &#8220;Send FaultReport&#8221;);<br \/>\nthread.start();<\/p>\n<p>}<br \/>\ncatch (Exception e) {<br \/>\nLog.e(Preferences.TAG_Restfull, &#8220;JSON ERROR:&#8221;, e);<br \/>\n}<br \/>\n}<br \/>\n}<br \/>\n[\/sourcecode]<br \/>\n[sourcecode language=&#8221;java&#8221;]<br \/>\npublic class JSONUtil {<\/p>\n<p>\/**<br \/>\n* Skicka JSON meddelande och g\u00c3\u00b6r \u00c3\u00a5terf\u00c3\u00b6rs\u00c3\u00b6k om det misslyckas<br \/>\n* @param url<br \/>\n* @param jsonObj Insert null if not parameters should be sent<br \/>\n* @param retry if SocketException<br \/>\n* @return<br \/>\n* @throws Exception<br \/>\n*\/<br \/>\npublic static String doPost(String url, JSONObject jsonObj, int retry) throws Exception {<br \/>\nException catchEd = null;<br \/>\nfor (int i = 0; i &lt; retry; i++){<br \/>\nif (Preferences.DEBUG)<br \/>\nLog.d(Preferences.TAG_Restfull, &#8220;JSON Try\/Retry:&#8221; + i + &#8221; : &#8221; + url);<br \/>\ntry {<br \/>\nreturn doPost(url, jsonObj);<br \/>\n}<br \/>\ncatch (SocketException soc){<br \/>\ncatchEd = soc;<br \/>\n}<br \/>\n}<br \/>\nthrow catchEd;<br \/>\n}<\/p>\n<p>\/**<br \/>\n* Do a post to an url with JSON object<br \/>\n*<br \/>\n* @param url<br \/>\n* @param jsonObj<br \/>\n* Insert null if not parameters should be sent<br \/>\n* @return JSONObject as response from service<br \/>\n* @throws ClientProtocolException<br \/>\n* @throws IOException<br \/>\n*\/<br \/>\npublic static String doPost(String url, JSONObject jsonObj) throws Exception {<br \/>\nString result = &#8220;&#8221;;<br \/>\ntry {<\/p>\n<p>DefaultHttpClient httpClient = (DefaultHttpClient) MySSLSocketFactory.getNewHttpClient();<br \/>\nHttpParams params = httpClient.getParams();<br \/>\nHttpConnectionParams.setConnectionTimeout(params, 10000);<br \/>\nHttpConnectionParams.setSoTimeout(params, 10000);<br \/>\nConnManagerParams.setTimeout(params, 10000);<br \/>\nHttpPost post;<br \/>\nif (jsonObj != null) {<br \/>\npost = new HttpPost(url + &#8220;?&#8221;);<br \/>\npost.setEntity(new StringEntity(jsonObj.toString(), &#8220;UTF-8&#8221;));<br \/>\n}<br \/>\nelse<br \/>\npost = new HttpPost(url);<\/p>\n<p>post.addHeader(&#8220;Content-Type&#8221;, &#8220;application\/json; charset=utf-8&#8221;);<\/p>\n<p>HttpResponse resp = httpClient.execute(post);<br \/>\nInputStream is = resp.getEntity().getContent();<br \/>\nBufferedReader br = new BufferedReader(new InputStreamReader(is));<br \/>\nString line;<br \/>\nwhile ((line = br.readLine()) != null)<br \/>\nresult += line;<br \/>\nbr.close();<\/p>\n<p>return result;<\/p>\n<p>}<br \/>\ncatch (Exception ex) {<br \/>\nthrow ex;<br \/>\n}<br \/>\n}<br \/>\n}<br \/>\n[\/sourcecode]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>FaultReporter Rest API Is a service (Open API) used to be able to report faults to, that occurs at products out at customers that you are not administrating over. Every product need to implement a send logic to send strange exceptions. First of you need to register a user. The email and privkey will be [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-876","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.lightsoftai.com\/index.php?rest_route=\/wp\/v2\/pages\/876","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.lightsoftai.com\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.lightsoftai.com\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.lightsoftai.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.lightsoftai.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=876"}],"version-history":[{"count":30,"href":"https:\/\/www.lightsoftai.com\/index.php?rest_route=\/wp\/v2\/pages\/876\/revisions"}],"predecessor-version":[{"id":1702,"href":"https:\/\/www.lightsoftai.com\/index.php?rest_route=\/wp\/v2\/pages\/876\/revisions\/1702"}],"wp:attachment":[{"href":"https:\/\/www.lightsoftai.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=876"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}