avi12
(avi6106@gmail.com)
December 6, 2022, 9:50am
1
As reported , I tried following the documentation :
const formData = new FormData();
formData.append("channel", "listed");
formData.append("upload", fs.createReadStream(xpiPath));
const response = await axios.post("https://addons.mozilla.org/api/v5/addons/upload", formData, {
headers: {
Authorization: `JWT ${token}`,
"Content-Type": "multipart/form-data"
}
});
console.log(response.data);
but instead of getting the following JSON structure:
{
"uuid": "",
"channel": "listed",
"processed": true,
"submitted": true,
"url": "",
"valid": true,
"validation": {},
"version": ""
}
Iām getting
{
"page_size": 25,
"page_count": 1,
"count": 0,
"next": null,
"previous": null,
"results": []
}
juhis
(Juha-Matti Santala)
December 9, 2022, 6:54pm
2
Hey @avi12 !
The response documentation that you are linking to, is a response for calling https://addons.mozilla.org/api/v5/addons/upload/{uuid}
where your call seems to be to the listing endpoint (without the {uuid} part): https://addons-server.readthedocs.io/en/latest/topics/api/addons.html#get--api-v5-addons-upload-
avi12
(avi6106@gmail.com)
December 9, 2022, 9:11pm
3
Indeed, it is very odd
Any idea how to fix this?
avi12
(avi6106@gmail.com)
December 12, 2022, 8:42pm
4
I found the issue
I thought I could send a request to /addons/upload
, but it turns out that as the documentation says, the server has a listener to /addons/upload/
, with the trailing /
For example, the following works:
const formData = new FormData();
formData.append("channel", "listed");
formData.append("upload", fs.createReadStream(xpiPath));
const response = await axios.post("https://addons.mozilla.org/api/v5/addons/upload/", formData, {
headers: {
Authorization: `JWT ${token}`,
"Content-Type": "multipart/form-data"
}
});
console.log(response.data);
2 Likes