AnyChart / export-server

Export Server is a Java based server intended for exporting charts in .pdf, .jpg, .png, .svg, .csv, .xslx, .json and .xml formats
http://export.anychart.com/status
Apache License 2.0
20 stars 6 forks source link

"data-type must be one of the values: svg, script" #1

Closed brianyang closed 7 years ago

brianyang commented 7 years ago

When I start the java server locally, and I make a post request, I get the following error:

Debug: internal, implementation, error Error: Error: got 400 response

here is my post request:


req.headers({
  "postman-token": "140201a0-f88d-e1ce-71f7-7cc5db863713",
  "content-type": "application/x-www-form-urlencoded",
  "cookie": "__lc.visitor_id.1006188=S1487415976.48ea09b190; autoinvite_callback=true; _cio=2ffabb54-4f57-e1dd-8803-0f68e415a1aa; user_segment=Prospect; lc_invitation_opened=opened; GAUI=58a82aa9b9dea; AB_TEST_VAR=a; _ga=GA1.2.928524982.1487415977; lc_window_state=minimized; __insp_wid=600032561; __insp_slim=1488518022481; __insp_nv=true; __insp_targlpu=https%3A%2F%2Fdocs.anychart.com%2F7.8.0%2FCommon_Settings%2FServer-side_Rendering; __insp_targlpt=Server-side%20Rendering%20%7C%20Common%20Settings%20%7C%20AnyChart%20Documentation%20ver.%207.8.0; __insp_norec_sess=true; _hp2_id.3941342819=%7B%22userId%22%3A%228903324589099993%22%2C%22pageviewId%22%3A%228322977263861317%22%2C%22sessionId%22%3A%221229000451437970%22%2C%22identity%22%3Anull%2C%22trackerVersion%22%3A%223.0%22%7D; _hp2_ses_props.3941342819=%7B%22r%22%3A%22http%3A%2F%2Fplayground.anychart.com%2Fgallery%2F7.13.0%2FQuadrant_Charts%2FBI_Services_Comparison%22%2C%22ts%22%3A1488519039354%2C%22d%22%3A%22playground.anychart.com%22%2C%22h%22%3A%22%2Fgallery%2F7.13.0%2FPie_and_Donut_Charts%2FPie_Chart%22%7D",
  "accept-language": "en-US,en;q=0.8",
  "accept-encoding": "gzip, deflate",
  "referer": "http://playground.anychart.com/gallery/7.13.0/Pie_and_Donut_Charts/Pie_Chart",
  "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
  "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
  "upgrade-insecure-requests": "1",
  "origin": "http://playground.anychart.com",
  "cache-control": "no-cache",
  "pragma": "no-cache",
  "content-length": "13527",
  "connection": "keep-alive",
  "host": "export.anychart.com"
})

I'm just proxying to the export-server hosted on anycharts

when i try this same request in postman, it returns an image.

does anybody know what's happening?

brianyang commented 7 years ago

it doesn't appear to need any headers. the request body should be json. it appears postman lets you send it as a urlencoded post request but that may not work elsewhere. here's working code:

req.send({
  "data": '<?xml version="1.0" encoding="UTF-8" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg" border="0" data-ac-wrapper-id="2" width="1539" height="1240" class="anychart-ui-support" role="presentation" style="display: block;"></svg>'
, "dataType": "svg"
, "responseType": "file"
, "file-name": "any"
})