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

הצטרף לדיון - הוסף תגובה למטה:

התחבר / הירשם כדי לפרסם תגובות חדשות