smartDocs: Uncaught TypeError: Cannot read property 'length'

Not applicable

OVERVIEW:

My apigee proxy works when I call it from postman, but when I call it from smartDocs the browser window shows “An internal error has occurred. Please retry your request.” Chrome developer console says the root cause is 502 bad gateway > Uncaught TypeError: Cannot read property 'length'

/products - returns all products, size = 13.61 MB, response takes 24 sec

  • Call works from postman
  • Call fails from smartDocs - but Trace shows http.status = 200

/products?skus=1,2,3 – returns a much smaller subset of products

  • Call works from postman
  • Call works from smartDocs


HYPOTHESIS: The response from /products is too big for smartDocs to handle


DETAILS:

Action 1: start Trace and call /products from smartDocs

Observation 1:

  • Trace shows http.status = 200
  • Chrome developer console shows a CORS error

XMLHttpRequest cannot load https://apiconsole-prod.apigee.net/smartdocs/v1/sendrequest?targeturl={my-target-url}. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://dev-{my-org}.devportal.apigee.com' is therefore not allowed access. The response had HTTP status code 502.

Action 2: Enable CORS with chrome plugin (NOTE: The other calls worked without enabling the CORS plugin)

Observation 2:

  • Chrome developer console shows a 502 Bad Gateway Error

GET https://apiconsole-prod.apigee.net/smartdocs/v1/sendrequest?targeturl={my-target-url} 502 (Bad Gateway)

Bad Gateway

Uncaught TypeError: Cannot read property 'length'

  • The response being sent from the proxy has a non-null content-length header

Thanks!

0 5 433
5 REPLIES 5

4126-screen-shot-2016-12-21-at-54540-pm.png

Have you tried disabling the Prism syntax highlighter from SmartDocs configuration? For large responses the library sometimes fails.

Or it could be the ajax request times out.

Not applicable

you able to figure out the reason? I am seeing the same issue

getting same error, @Michael Haggerty where you able to find the root cause for this issue. Thanks

This issue was resolved after correcting the smardocs endpoint url.
/sendRequest suffix was missing in smartdocs endpoint url in developer portal