Title: [Android] Unable to handle error response coming from server · Issue #282 · NativeScript/nativescript-background-http · GitHub
Open Graph Title: [Android] Unable to handle error response coming from server · Issue #282 · NativeScript/nativescript-background-http
X Title: [Android] Unable to handle error response coming from server · Issue #282 · NativeScript/nativescript-background-http
Description: Please, tell us how to recreate the issue in as much detail as possible. when api fails with 400 status server is sending error response but I'm unable to read it, I'm able read response only in case of success. Package.json ` "tns-andro...
Open Graph Description: Please, tell us how to recreate the issue in as much detail as possible. when api fails with 400 status server is sending error response but I'm unable to read it, I'm able read response only in ca...
X Description: Please, tell us how to recreate the issue in as much detail as possible. when api fails with 400 status server is sending error response but I'm unable to read it, I'm able read response on...
Opengraph URL: https://github.com/NativeScript/nativescript-background-http/issues/282
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Android] Unable to handle error response coming from server","articleBody":"### Please, tell us how to recreate the issue in as much detail as possible. \r\nwhen api fails with 400 status server is sending error response but I'm unable to read it, I'm able read response only in case of success.\r\n\r\n### Package.json\r\n\r\n `\r\n \r\n \"tns-android\": {\r\n \"version\": \"6.5.3\"\r\n },\r\n \"tns-ios\": {\r\n \"version\": \"6.5.4\"\r\n }\r\n },\r\n \"scripts\": {\r\n \"clean\": \"tns platform clean ios \u0026\u0026 tns platform clean android\",\r\n \"android\": \"tns run android --env.aot\",\r\n \"ios\": \"tns run ios --env.aot\",\r\n \"ios-prod\": \"tns run ios --env.aot --env.name=production\",\r\n \"android-prod\": \"tns run android --env.aot --env.name=production\",\r\n \"deploy\": \"./appcenter_deploy.sh \",\r\n \"lint\": \"tslint \\\"src/**/*.ts\\\"\"\r\n },\r\n \"dependencies\": {\r\n \"@angular/animations\": \"~8.2.0\",\r\n \"@angular/common\": \"~8.2.0\",\r\n \"@angular/compiler\": \"~8.2.0\",\r\n \"@angular/core\": \"~8.2.0\",\r\n \"@angular/forms\": \"~8.2.0\",\r\n \"@angular/http\": \"8.0.0-beta.10\",\r\n \"@angular/platform-browser\": \"~8.2.0\",\r\n \"@angular/platform-browser-dynamic\": \"~8.2.0\",\r\n \"@angular/router\": \"~8.2.0\",\r\n \"@ngx-translate/core\": \"^11.0.1\",\r\n \"@ngx-translate/http-loader\": \"^4.0.0\",\r\n \"@ngxs-labs/emitter\": \"^2.0.0\",\r\n \"@ngxs/store\": \"^3.6.1\",\r\n \"@nstudio/nativescript-cardview\": \"^1.0.0\",\r\n \"@nstudio/nativescript-checkbox\": \"^1.0.0\",\r\n \"@nstudio/nativescript-loading-indicator\": \"3.0.4\",\r\n \"@nstudio/nativescript-pulltorefresh\": \"^1.1.1\",\r\n \"ajv\": \"^6.10.0\",\r\n \"base-64\": \"^0.1.0\",\r\n \"bootstrap\": \"^4.3.1\",\r\n \"core-js\": \"3.4.1\",\r\n \"d3-ease\": \"^1.0.6\",\r\n \"i\": \"^0.3.6\",\r\n \"jquery\": \"^3.4.1\",\r\n \"moment\": \"^2.24.0\",\r\n \"nativescript-android-utils\": \"^1.0.2\",\r\n \"nativescript-angular\": \"^8.20.1\",\r\n \"nativescript-appavailability\": \"^1.3.2\",\r\n \"nativescript-appversion\": \"^1.4.2\",\r\n \"nativescript-audio\": \"^5.0.5\",\r\n \"nativescript-azure-mobile-apps\": \"^2.0.3\",\r\n \"nativescript-background-http\": \"4.2.0\",\r\n \"nativescript-camera\": \"^4.5.0\",\r\n \"nativescript-drawingpad\": \"^3.1.0\",\r\n \"nativescript-drop-down\": \"^5.0.4\",\r\n \"nativescript-email\": \"^1.5.5\",\r\n \"nativescript-exit\": \"^1.0.1\",\r\n \"nativescript-fingerprint-auth\": \"^7.0.2\",\r\n \"nativescript-geolocation\": \"^5.1.0\",\r\n \"nativescript-imagepicker\": \"^7.1.0\",\r\n \"nativescript-iqkeyboardmanager\": \"^1.5.1\",\r\n \"nativescript-local-notifications\": \"^4.1.5\",\r\n \"nativescript-mediafilepicker\": \"^3.0.1\",\r\n \"nativescript-microsoft-appcenter\": \"^2.0.0\",\r\n \"nativescript-permissions\": \"^1.3.8\",\r\n \"nativescript-phone\": \"^1.4.0\",\r\n \"nativescript-photo-editor\": \"^1.1.0\",\r\n \"nativescript-plugin-firebase\": \"^10.3.1\",\r\n \"nativescript-secure-storage\": \"^2.6.0\",\r\n \"nativescript-swiss-army-knife\": \"^4.0.2\",\r\n \"nativescript-theme-core\": \"^2.0.24\",\r\n \"nativescript-toasty\": \"^3.0.0-alpha.2\",\r\n \"nativescript-ui-calendar\": \"^6.0.0\",\r\n \"nativescript-ui-dataform\": \"^6.0.0\",\r\n \"nativescript-ui-listview\": \"^8.0.0\",\r\n \"nativescript-ui-sidedrawer\": \"^8.0.0\",\r\n \"npm\": \"^6.14.4\",\r\n \"popper.js\": \"^1.15.0\",\r\n \"reflect-metadata\": \"~0.1.12\",\r\n \"rxjs\": \"^6.4.0\",\r\n \"tns-core-modules\": \"^6.5.20\",\r\n \"zone.js\": \"^0.9.1\"\r\n },\r\n \"devDependencies\": {\r\n \"@angular-devkit/build-angular\": \"^0.901.0\",\r\n \"@angular/cli\": \"^8.3.18\",\r\n \"@angular/compiler-cli\": \"~8.2.0\",\r\n \"@nativescript/schematics\": \"~0.7.3\",\r\n \"@ngtools/webpack\": \"~8.2.0\",\r\n \"@types/d3-ease\": \"^1.0.9\",\r\n \"@types/jasmine\": \"2.8.6\",\r\n \"@types/jasminewd2\": \"~2.0.3\",\r\n \"@types/node\": \"12.6.3\",\r\n \"codelyzer\": \"^5.0.1\",\r\n \"nativescript-dev-webpack\": \"^1.5.1\",\r\n \"node-sass\": \"^4.13.1\",\r\n \"protractor\": \"^6.0.0\",\r\n \"tns-android\": \"6.5.3\",\r\n \"tns-ios\": \"6.5.4\",\r\n \"tns-platform-declarations\": \"6.4.2\",\r\n \"ts-node\": \"8.5.0\",\r\n \"tslint\": \"5.18.0\",\r\n \"typescript\": \"3.4.5\"\r\n },\r\n }\r\n `\r\n\r\n### muitipart-handler.service\r\n`public multipartUpload(url: string, token: string, bgSessionName: string,\r\n params: any, androidNotificationTitle: string = 'Sync complete') {\r\n\r\n const session = bgHttp.session(bgSessionName);\r\n const name = 'test';\r\n const description = `${name} (${++this.counter})`;\r\n const request = {\r\n url: url,\r\n method: 'POST',\r\n headers: {\r\n Authorization: this.apiHelper.getAuthHeaderAsString(token),\r\n 'Content-Disposition': 'form-data; name=' + name + 'filename=' + name,\r\n 'Content-Type': 'application/octet-stream'\r\n\r\n },\r\n description: description,\r\n androidAutoDeleteAfterUpload: false,\r\n androidNotificationTitle: androidNotificationTitle,\r\n androidAutoClearNotification: true\r\n };\r\n\r\n setTimeout(() =\u003e { // Timeout of 20 seconds. If the upload doesn't complete in 20 seconds. it will return a 408.\r\n if (!this.finishedUploading) {\r\n this.response.next({responseCode: 408, data: 'Multipart upload timed out'});\r\n }\r\n }, 20000);\r\n\r\n const task = session.multipartUpload(params, request);\r\n this.bindTask(task);\r\n return this.response;\r\n }\r\n\r\n /**\r\n * Bind the task to the events. This will create callbacks for every stage of the call.\r\n * (responsed, progress, complete, error)\r\n *\r\n * To get the response code and data from the response, please subscribe on MultipartHandlerService.response\r\n *\r\n * @param task - bgHttp.Task\r\n */\r\n private bindTask(task: bgHttp.Task): any {\r\n task.on('progress', this.onEvent.bind(this));\r\n task.on('error', this.onEvent.bind(this));\r\n task.on('responded', this.onEvent.bind(this));\r\n task.on('complete', this.onEvent.bind(this));\r\n this.lastEvent = '';\r\n }\r\n\r\n private onEvent(e): Observable\u003cboolean\u003e {\r\n if (this.lastEvent !== e.eventName) {\r\n // suppress all repeating progress events and only show the first one\r\n this.lastEvent = e.eventName;\r\n } else {\r\n return;\r\n }\r\n if ( e.eventName === 'complete') {\r\n console.log('completehandler')\r\n this.finishedUploading = true;\r\n this.response.next({responseCode: e.responseCode, data: JSON.parse(this.data)});\r\n }\r\n\r\n if ( e.eventName === 'responded') {\r\n console.log('respondhandler')\r\n this.data = e.data;\r\n console.log(e.data)\r\n }\r\n\r\n if ( e.eventName === 'error') {\r\n console.log(`Multipart HTTP error.\r\n ResponseCode: ${e.responseCode},\r\n Response: ${e.response}`);\r\n }\r\n\r\n this.events.push({\r\n eventTitle: e.eventName + ' ' + e.object.description,\r\n eventData: JSON.stringify({\r\n error: e.error ? e.error.toString() : e.error,\r\n currentBytes: e.currentBytes,\r\n totalBytes: e.totalBytes,\r\n body: e.data,\r\n responseCode: e.responseCode\r\n })\r\n });\r\n }\r\n}\r\n`\r\n","author":{"url":"https://github.com/Srikanthjava972","@type":"Person","name":"Srikanthjava972"},"datePublished":"2022-02-01T10:42:34.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/282/nativescript-background-http/issues/282"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:a24b40ac-df6e-5172-7d96-dc4cdc314c8d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 927A:EBF9C:25E6702:31FA2B5:6992DCEF |
| html-safe-nonce | 0f44fe124fe1b8be0dea240d92045fb907028a8f9032c81c61bb8142af6f8189 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MjdBOkVCRjlDOjI1RTY3MDI6MzFGQTJCNTo2OTkyRENFRiIsInZpc2l0b3JfaWQiOiI0MDQ1NjY2NjU5ODA5Mjg3NDA3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | c8f0de02b9c12b4ea635f65b24d4cdd5285e6de8a5f1a25e935bf27613b1b5c2 |
| hovercard-subject-tag | issue:1120500600 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/NativeScript/nativescript-background-http/282/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ec26ed4baf9e9dab802108ba0feaed23ac22e3f508e10cfe8bc44cf1cf2c89e7/NativeScript/nativescript-background-http/issues/282 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ec26ed4baf9e9dab802108ba0feaed23ac22e3f508e10cfe8bc44cf1cf2c89e7/NativeScript/nativescript-background-http/issues/282 |
| og:image:alt | Please, tell us how to recreate the issue in as much detail as possible. when api fails with 400 status server is sending error response but I'm unable to read it, I'm able read response only in ca... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Srikanthjava972 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 42c603b9d642c4a9065a51770f75e5e27132fef0e858607f5c9cb7e422831a7b |
| turbo-cache-control | no-preview |
| go-import | github.com/NativeScript/nativescript-background-http git https://github.com/NativeScript/nativescript-background-http.git |
| octolytics-dimension-user_id | 7392261 |
| octolytics-dimension-user_login | NativeScript |
| octolytics-dimension-repository_id | 41672178 |
| octolytics-dimension-repository_nwo | NativeScript/nativescript-background-http |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 41672178 |
| octolytics-dimension-repository_network_root_nwo | NativeScript/nativescript-background-http |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 84dcb133269e3cfe6e0296cc85fbacb92cae92bb |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width