instant PDF

GRATIS
Door yogthos | Bijgewerkt 1ヶ月前 | Data
Populariteit

5.8 / 10

Latency

58ms

Serviceniveau

100%

Health Check

N/A

Terug naar alle discussies

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

Doe mee aan de discussie - voeg hieronder een opmerking toe

Log in / Schrij u in om nieuwe opmerkingen te plaatsen