instant PDF

無料
よって yogthos | 更新済み לפני חודש | Data
人気

5.9 / 10

レイテンシー

58ms

サービスレベル

100%

Health Check

N/A

すべてのディスカッションに戻る

'Invalid Request ' response when made from NodeJS

Rapid account: Adekola
adekola
לפני 9 שנים

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 שנים

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 שנים

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 שנים

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"]]'

ディスカッションに参加しましょう-以下にコメントを追加してください:

ログイン/サインアップして新しいコメントを投稿