0

I have angular and dotnet core template app in same directory.

I have to upload build on azure server but I'm getting this error. Please guide me how I can fix this problem.

Production:

ERROR Error: Uncaught (in promise): TR: {"headers":{"normalizedNames":{},"lazyUpdate":null},"status":200,"statusText":"OK","url":"https://admin-dev.xperters.com/api/jobs/getJobs","ok":false,"name":"HttpErrorResponse","message":"Http failure during parsing for https://admin-dev.xperters.com/api/jobs/getJobs","error":{"error":{},"text":"<!DOCTYPE html><html lang=\"en\"><head>\n  <meta charset=\"utf-8\">\n  <title>Xperters</title>\n  <base href=\"/\">\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n  <link rel=\"icon\" type=\"image/x-icon\" href=\"https://files.xperters.com/images/favicon.webp\">\n  <link href=\"https://unpkg.com/boxicons@2.0.9/css/boxicons.min.css\" rel=\"stylesheet\">\n  <link rel=\"stylesheet\" type=\"text/css\" href=\"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.9.0/css/all.css\">\n<style>@charset \"UTF-8\";@import url(https://fonts.googleapis.com/css?family=Roboto:300,400,500,700);@import url(https://fonts.googleapis.com/earlyaccess/notokufiarabic.css);html{font-family:sans-serif;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}body{margin:0}:after,:before{box-sizing:border-box}html{font-size:10px;-webkit-tap-highlight-color:rgba(0,0,0,0)}body{font-family:Helvetica Neue,Helvetica,Arial,sans-serif;font-size:14px;line-height:1.42857143;color:#333;background-color:#fff}body,html{margin:0;min-height:100%;height:100%}*{box-sizing:border-box}</style><link rel=\"stylesheet\" href=\"styles.15db04db7ed750153d26.css\" media=\"print\" onload=\"this.media='all'\"><noscript><link rel=\"stylesheet\" href=\"styles.15db04db7ed750153d26.css\"></noscript></head>\n\n<body class=\"dx-viewport\">\n  <app-root></app-root>\n<script src=\"runtime.03132d1f1e3c790b12ce.js\" defer></script><script src=\"polyfills.0087e061b20969056b57.js\" defer></script><script src=\"main.9d0e9744df940a9c2e1d.js\" defer></script>\n\n</body></html>"}}
at G (polyfills.0087e061b20969056b57.js:1)
at polyfills.0087e061b20969056b57.js:1
at Ee (main.9d0e9744df940a9c2e1d.js:1)
at T.invoke (polyfills.0087e061b20969056b57.js:1)
at Object.onInvoke (main.9d0e9744df940a9c2e1d.js:1)
at T.invoke (polyfills.0087e061b20969056b57.js:1)
at I.run (polyfills.0087e061b20969056b57.js:1)
at polyfills.0087e061b20969056b57.js:1
at T.invokeTask (polyfills.0087e061b20969056b57.js:1)
at Object.onInvokeTask (main.9d0e9744df940a9c2e1d.js:1)

localhost:

ERROR Error: Uncaught (in promise): HttpErrorResponse: {"headers":{"normalizedNames":{},"lazyUpdate":null,"headers":{}},"status":0,"statusText":"Unknown Error","url":"https://admin-dev.xperters.com/api/jobs/getJobs","ok":false,"name":"HttpErrorResponse","message":"Http failure response for https://admin-dev.xperters.com/api/jobs/getJobs: 0 Unknown Error","error":{"isTrusted":true}}
at resolvePromise (zone.js:1213)
at zone.js:1120
at rejected (index.ts:1)
at ZoneDelegate.invoke (zone.js:372)
at Object.onInvoke (core.js:28692)
at ZoneDelegate.invoke (zone.js:371)
at Zone.run (zone.js:134)
at zone.js:1276
at ZoneDelegate.invokeTask (zone.js:406)
at Object.onInvokeTask (core.js:28679)
Amir Sohail
  • 21
  • 1
  • 3

1 Answers1

1

It is always recommended to provide the code you are working on along with the error you are getting as it help us to reproduce the problem and provide you the solution.

So now I can only tell you the reasons why you may be getting this issue. There are three possible reasons as for getting this error as mentioned below. Please check all the reason and follow them to solve the problem.

  1. Invalid JSON format

    One of the possible reason why you are getting this error is that you have an incorrect format of your JSON. From the network tab copy the response and validate it via JSON validator.

  2. Wrong ResponseType

    Another reason can be HttpClient by default converts response to be response.json(). In case you are API returns non-json response, you have to specify that as shown below.

    return this.http.get/post(url, {responseType: 'text'}).
    
  3. Invisible \0 character in the response

    If you already validated JSON in the JSON validation tool and setting the responseType didn't help, try getting the json from your backend and see if there are any \0 characters. To fix this in C# you can do something like this:

    result.FieldWithStackTrace = result.FieldWithStackTrace?.Replace("\0", string.Empty);
    

I would suggest you to read this Angular documentation for more information. Also check this answer and other responses to the similar Stack overflow thread.

SauravDas-MT
  • 1,224
  • 1
  • 4
  • 10