{ "id": "151275", "key": "TIMOB-19564", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "14826", "description": "Release 5.1.0-remaining iOS9 features, Android M features", "name": "Release 5.1.0", "archived": false, "released": true, "releaseDate": "2015-11-20" } ], "resolution": { "id": "11", "description": "Is not a bug in our product", "name": "Not Our Bug" }, "resolutiondate": "2016-03-11T08:59:52.000+0000", "created": "2015-09-18T14:58:09.000+0000", "priority": { "name": "High", "id": "2" }, "labels": [ "5.0.0.GA", "android", "httpclient", "look1", "patch" ], "versions": [ { "id": "16925", "description": "WatchKit Support--all going into 5.0 now", "name": "Release 5.0.0", "archived": true, "released": true, "releaseDate": "2015-09-16" } ], "issuelinks": [ { "id": "51174", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "outwardIssue": { "id": "130804", "key": "TIMOB-17145", "fields": { "summary": "Android: Add support to HTTPClient for PATCH requests", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "priority": { "name": "Medium", "id": "3" }, "issuetype": { "id": "2", "description": "A new feature of the product, which has yet to be developed.", "name": "New Feature", "subtask": false } } } } ], "assignee": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2018-08-06T17:52:04.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "From release 5.0.0, the patch method doesn't work.\r\n{code}\r\n5.0.0.GA\r\nandroid:targetSdkVersion=\"23\"\r\nandroid device version=4.3\r\n{code}\r\n\r\nCONSOLE :\r\n{code}\r\n[ERROR] : TiHTTPClient: (TiHttpClient-19) [18578,155345] HTTP Error (java.net.ProtocolException): Unknown method 'PATCH'; must be one of [OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE]\r\n[ERROR] : TiHTTPClient: java.net.ProtocolException: Unknown method 'PATCH'; must be one of [OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE]\r\n[ERROR] : TiHTTPClient: \tat java.net.HttpURLConnection.setRequestMethod(HttpURLConnection.java:677)\r\n[ERROR] : TiHTTPClient: \tat ti.modules.titanium.network.TiHTTPClient$ClientRunnable.run(TiHTTPClient.java:1124)\r\n{code}", "attachment": [], "flagged": false, "summary": "Android: HttpClient patch method doesn't work from 5.0.0", "creator": { "name": "AurelienH", "key": "aurelienh", "displayName": "Aurélien HUET", "active": true, "timeZone": "Europe/Paris" }, "subtasks": [], "reporter": { "name": "AurelienH", "key": "aurelienh", "displayName": "Aurélien HUET", "active": true, "timeZone": "Europe/Paris" }, "environment": null, "closedSprints": [ { "id": 494, "state": "closed", "name": "2015 Sprint 20 SDK", "startDate": "2015-09-26T00:29:19.845Z", "endDate": "2015-10-10T00:29:00.000Z", "completeDate": "2015-10-12T05:33:30.964Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "364569", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "[~aurelien.huet] Would you be able to provide the endpoint API for patch for testing?\r\n\r\nWould your endpoint respect the header `X-HTTP-Method-Override` for PATCH?", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2015-09-22T03:44:47.000+0000", "updated": "2015-09-22T04:13:13.000+0000" }, { "id": "364591", "author": { "name": "AurelienH", "key": "aurelienh", "displayName": "Aurélien HUET", "active": true, "timeZone": "Europe/Paris" }, "body": "Try with this URL and the body at the end (content-type=application/json)\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I6IjE0NDI5MDgwMjAifQ.txpb2RQUGl62FEO0NcS6KSqszOE_t_Bze9yxBKQCzUS1-yPzLz3pkH4_vodkFb-Xgx8TztTFq6JJsy-06A0xfuB5kyKi5BS85PHoInE_5sQzAfPWvM1YJNedyfRwh31XFagdGp5zEETI5EWq881LPjInx1otelQ8PcicsIw7CvdPMaJjYxKaX38Ch65jlfzAKA5gZ7iZrNmcmO5qRwWtqqQ-LDVw7DBXv-Z-Q1onOBPMKSIjsw73lSYOt_J3bUh5jYA555rclS9S71BpjHjRj7hGXSO0J4DQNcOT7nzBpEw4nKt1I4i-uiegSRCnav-a50JmC6ScjAqSlxD8WQbrddT5ujrI-BHV1n2BGg-aHZIix2be8Vdvxwu2vgM6Q-pBzKtS5-mU-Q_ShwdeBDgI2IbAkf6afvtKKllZKw18pJQ22hAnInkTk6tXQVbayMki4Feov_5eqUKVDnhChWCpdX7gp2AUaT2vmfhE8axk9r6BZXac_bXQp7lBlhyJvJvTKrC16dEQNBba6_TrCRJqk8azqBfsqo_FkIO8KgDrAwqrba9IL3XVRc8ylpzk6gPPrX-P-6WaBMcgMnURrmjpb83TvC3XdU-cVOElo7w81XbMaY-T-0EfZIdVoSfqv9BeMLNenXPKLLvtUg0DIk4pDa33A1zBZH08G5h1NGmqBHw\r\n\r\nbody:{\"deliver_address\":27,\"invoice_address\":27}", "updateAuthor": { "name": "AurelienH", "key": "aurelienh", "displayName": "Aurélien HUET", "active": true, "timeZone": "Europe/Paris" }, "created": "2015-09-22T07:55:31.000+0000", "updated": "2015-09-22T07:55:31.000+0000" }, { "id": "364594", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "Thank you [~aurelien.huet] ", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2015-09-22T08:31:38.000+0000", "updated": "2015-09-22T08:31:38.000+0000" }, { "id": "364601", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "[~aurelien.huet] The link you send me seems down at the moment. Could you try this with the api that you want to patch.\r\n\r\n{code}\r\n \r\n \r\nvar win = Ti.UI.createWindow({backgroundColor: 'white'});\r\n \r\n\r\nvar url = \"http://httpbin.org/patch?address=07645\";\r\n \r\nvar client = Ti.Network.createHTTPClient({\r\n \r\n // function called when the response data is available\r\n \r\n onload : function(e) {\r\n \r\n Ti.API.info(\"Received text: \" + this.responseText);\r\n \r\n alert('success');\r\n \r\n },\r\n \r\n // function called when an error occurs, including a timeout\r\n \r\n onerror : function(e) {\r\n \r\n Ti.API.debug(e.error);\r\n \r\n alert('error');\r\n \r\n },\r\n \r\n timeout : 5000 // in milliseconds\r\n \r\n});\r\n \r\n// Prepare the connection.\r\n \r\nclient.open(\"POST\", url);\r\nclient.setRequestHeader(\"X-HTTP-Method-Override\", \"PATCH\"); \r\n\r\n// Send the request.\r\nvar body = {\"deliver_address\":27,\"invoice_address\":27} \r\n \r\nclient.send(body);\r\n \r\nwin.open();\r\n{code}\r\n\r\nDo change the url and the body. What's happening in this code is that it is set as POST and then a header X-HTTP-Method-Override is set to Patch. If the endpoint respects this header, it will treat it as a Patch request. Could you see if this works for you?", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2015-09-22T09:05:37.000+0000", "updated": "2015-09-22T09:05:37.000+0000" }, { "id": "364602", "author": { "name": "AurelienH", "key": "aurelienh", "displayName": "Aurélien HUET", "active": true, "timeZone": "Europe/Paris" }, "body": "Ashraf Abu Here's the answer :\r\n\r\nTiHTTPClient: (TiHttpClient-2) [1078,6862] HTTP Error (java.io.IOException): 405 : METHOD NOT ALLOWED\r\n[ERROR] : TiHTTPClient: java.io.IOException: 405 : METHOD NOT ALLOWED\r\n[ERROR] : TiHTTPClient: \tat ti.modules.titanium.network.TiHTTPClient$ClientRunnable.run(TiHTTPClient.java:1213)\r\n[ERROR] : TiHTTPClient: \tat java.lang.Thread.run(Thread.java:841)", "updateAuthor": { "name": "AurelienH", "key": "aurelienh", "displayName": "Aurélien HUET", "active": true, "timeZone": "Europe/Paris" }, "created": "2015-09-22T09:40:20.000+0000", "updated": "2015-09-22T16:04:33.000+0000" }, { "id": "364758", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "[~aurelien.huet] Thanks for the information!", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2015-09-23T03:46:55.000+0000", "updated": "2015-09-23T03:46:55.000+0000" }, { "id": "364965", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "Related Google Android ticket: https://code.google.com/p/android/issues/detail?id=76611", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2015-09-25T04:22:01.000+0000", "updated": "2015-09-25T04:22:01.000+0000" }, { "id": "365339", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "[~aurelien.huet] Here is a workaround.\r\n\r\nIt is a module for httpclient based on OkHttp. You can download ti.okhttp-android-0.0.1.zip from here: https://github.com/ashcoding/ti.okhttp/releases \r\n\r\nTo see an example, go here: https://github.com/ashcoding/ti.okhttp/blob/master/example/app.js\r\n\r\nThis client allows you to upload and use the PATCH method. This client does not allow you to download any file at the moment at this initial version. For downloads, please use the normal http client.\r\n\r\nLet me know if it works for you!\r\n\r\nResolving this ticket.", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2015-09-30T01:32:23.000+0000", "updated": "2015-09-30T01:32:23.000+0000" }, { "id": "379373", "author": { "name": "Mark_Boyer", "key": "mark_boyer", "displayName": "Mark Boyer", "active": true, "timeZone": "America/Los_Angeles" }, "body": "This is still broken with SDK 5.1.2GA and 5.2.0GA. Throws the following:\r\n\r\n\r\n{code:java}\r\n[ERROR] : TiHTTPClient: (TiHttpClient-19) [13162,99993] HTTP Error (java.net.ProtocolException): Unknown method 'PATCH'; must be one of [OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE]\r\n[ERROR] : TiHTTPClient: java.net.ProtocolException: Unknown method 'PATCH'; must be one of [OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE]\r\n[ERROR] : TiHTTPClient: \tat java.net.HttpURLConnection.setRequestMethod(HttpURLConnection.java:685)\r\n[ERROR] : TiHTTPClient: \tat com.android.okhttp.internal.http.HttpsURLConnectionImpl.setRequestMethod(HttpsURLConnectionImpl.java:144)\r\n[ERROR] : TiHTTPClient: \tat ti.modules.titanium.network.TiHTTPClient$ClientRunnable.run(TiHTTPClient.java:1137)\r\n[ERROR] : TiHTTPClient: \tat java.lang.Thread.run(Thread.java:841)\r\n[WARN] : W/System.err: java.lang.NullPointerException\r\n[WARN] : W/System.err: \tat ti.modules.titanium.network.TiHTTPClient.getAllResponseHeaders(TiHTTPClient.java:615)\r\n[WARN] : W/System.err: \tat ti.modules.titanium.network.HTTPClientProxy.getAllResponseHeaders(HTTPClientProxy.java:99)\r\n[WARN] : W/System.err: \tat org.appcelerator.kroll.runtime.v8.V8Object.nativeCallProperty(Native Method)\r\n[WARN] : W/System.err: \tat org.appcelerator.kroll.runtime.v8.V8Object.callProperty(V8Object.java:73)\r\n[WARN] : W/System.err: \tat org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1155)\r\n[WARN] : W/System.err: \tat android.os.Handler.dispatchMessage(Handler.java:98)\r\n[WARN] : W/System.err: \tat android.os.Looper.loop(Looper.java:136)\r\n[WARN] : W/System.err: \tat org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:118)\r\n[ERROR] : TiExceptionHandler: (main) [42,100035] ----- Titanium Javascript Runtime Error -----\r\n[ERROR] : TiExceptionHandler: (main) [1,100036] - In alloy/widgets/com.rainforrent.crmdynamics/controllers/crmView.js:254,50\r\n[ERROR] : TiExceptionHandler: (main) [0,100036] - Message: Uncaught Error: Java Exception occurred\r\n[ERROR] : TiExceptionHandler: (main) [0,100036] - Source: Ti.API.info(\"Error: \" + JSON.stringify(_evt));\r\n[ERROR] : V8Exception: Exception occurred at alloy/widgets/com.rainforrent.crmdynamics/controllers/crmView.js:254: Uncaught Error: Java Exception occurred\r\n[WARN] : W/System.err: java.lang.NullPointerException\r\n[WARN] : W/System.err: \tat ti.modules.titanium.network.TiHTTPClient.getAllResponseHeaders(TiHTTPClient.java:615)\r\n[WARN] : W/System.err: \tat ti.modules.titanium.network.HTTPClientProxy.getAllResponseHeaders(HTTPClientProxy.java:99)\r\n[WARN] : W/System.err: \tat org.appcelerator.kroll.runtime.v8.V8Object.nativeCallProperty(Native Method)\r\n[WARN] : W/System.err: \tat org.appcelerator.kroll.runtime.v8.V8Object.callProperty(V8Object.java:73)\r\n[WARN] : W/System.err: \tat org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1155)\r\n[WARN] : W/System.err: \tat android.os.Handler.dispatchMessage(Handler.java:98)\r\n[WARN] : W/System.err: \tat android.os.Looper.loop(Looper.java:136)\r\n[WARN] : W/System.err: \tat org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:118)\r\n{code}\r\n\r\nAs a side not, how can this ticket be marked as resolved and the pull request marked as declined?\r\n", "updateAuthor": { "name": "Mark_Boyer", "key": "mark_boyer", "displayName": "Mark Boyer", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2016-03-09T19:52:48.000+0000", "updated": "2016-03-09T19:52:48.000+0000" }, { "id": "379408", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "[~Mark_Boyer] Thanks for the message. This is set as resolved as it's an Android issue. \r\nhttps://code.google.com/p/android/issues/detail?id=76611\r\n(Maybe a better resolution might have been `Not Our Bug` on hindsight. But there's some workaround you can do for this hence `resolved` was chosen)\r\n\r\nThe HttpURLConnection by Android, does not support PATCH. This can be seen in the error message you received, {quote}java.net.ProtocolException: Unknown method 'PATCH'; must be one of [OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE]{quote}\r\n\r\nThe issue ticket by Android mentioned that they are putting in PATCH in future Android versions but does not provide additional information.\r\n\r\nIs there something you need to do that requires you to do a PATCH request?", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2016-03-10T04:51:46.000+0000", "updated": "2016-03-10T04:51:46.000+0000" }, { "id": "390361", "author": { "name": "Yrkh8trnoy", "key": "yrkh8trnoy", "displayName": "Kiley Williams", "active": true, "timeZone": "America/Vancouver" }, "body": "Is this ever going to get fixed as a part of CORE titanium? We are currently using the OKHttp module, but I'd like to use a more uniform, native approach.", "updateAuthor": { "name": "Yrkh8trnoy", "key": "yrkh8trnoy", "displayName": "Kiley Williams", "active": true, "timeZone": "America/Vancouver" }, "created": "2016-07-11T19:59:00.000+0000", "updated": "2016-07-11T19:59:00.000+0000" }, { "id": "390426", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "HttpURLConnection's implementation is by Android. From that I can say safely say that up till Android SDK 6 (Marshmellow) won't support Patch. As mentioned in earlier comments, https://code.google.com/p/android/issues/detail?id=76611 is the issue ticket in Android by Google that tracks this issue.\r\n\r\nThat being said, I am all for a more uniform approach. If there is a better way to get this implemented, it should be investigated to improve this.\r\n\r\nAny suggestion is greatly appreciated.", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2016-07-12T04:25:50.000+0000", "updated": "2016-07-12T04:25:50.000+0000" }, { "id": "440262", "author": { "name": "emerriman", "key": "emerriman", "displayName": "Eric Merriman ", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Closing as \"not our bug\". If you disagree, please reopen.", "updateAuthor": { "name": "emerriman", "key": "emerriman", "displayName": "Eric Merriman ", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-08-06T17:52:04.000+0000", "updated": "2018-08-06T17:52:04.000+0000" } ], "maxResults": 32, "total": 32, "startAt": 0 } } }