-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
I wrote a script to bulk upload a bunch of files to an API. One of the files was named yellow-café-au-lait-bowls-vintage_3.tif. The accented 'e' caused the API to return an error parsing the JSON.
The following addition to a helper function resolved the problem:
if (method === 'get') {
return bhttp[method](`${config.apiBase}${path}${query}`, opts);
} else if (method === 'post') {
return bhttp[method](`${config.apiBase}${path}`, params, opts);
} else if (method === 'rawpost') {
opts.method = 'POST';
opts.encodeJSON = false;
opts.inputBuffer = Buffer.from(JSON.stringify(params));
opts.headers['Content-Type'] = 'application/json';
return bhttp.request(`${config.apiBase}${path}`, opts);
}As far as I can tell, something about the post helper method being passed an object with utf-8 text in the value is causing problems. The API is https so I can't easily sniff the data; if this is enough info to go on then great. If you need more info, let me know what could help.
Metadata
Metadata
Assignees
Labels
No labels