instant PDF

免费
通过 yogthos | 已更新 a month ago | Data
人气

5.8 / 10

延迟

58ms

服务等级

100%

Health Check

N/A

返回所有讨论

'Invalid Request ' response when made from NodeJS

Rapid account: Adekola
adekola
9 years ago

When I test the endpoint on Mashape, it works perfectly. However, running the same Node sample code from within the node environment produces an error response with ‘Invalid Request’ body.

Why is this ? Is there something I am doing wrongly?

Rapid account: Yogthos
yogthos Commented 9 years ago

The response is binary data, so you can’t decode it as a string. you have to save the bytes from the response to a file.

Rapid account: Adekola
adekola Commented 9 years ago

Thanks yogthos. I got a fix sometime later from the mashape team.

There’s yet another issue which i’m sure you can answer. When i get the response from the endpoint, it comes in a format ready to be saved as per the headr field ‘Content-disposition: filename=document.pdf’.

Can you please tell what encoding is used to the response? I have tried ‘base64’, ‘utf8’ as well as ‘ascii’.

Looking forward to your response.

Thaks

Rapid account: Yogthos
yogthos Commented 9 years ago

I’m not really familiar with Node myself, but you might want to compare the request generated by node to the test request using curl. You have to make sure you’re including your mashape key header and so on.

curl -X POST --include 'https://yogthos.p.mashape.com/' \
  -H 'X-Mashape-Key: <your key>' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -d 'json-input=[{}, ["paragraph", "some text"]]'

加入讨论 - 在下面添加评论:

登录/注册以发布新的评论