Cannot update add-ons using the new submission API

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": [] 
}

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-

Indeed, it is very odd
Any idea how to fix this?

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