When trying to make a post call to the /library endpoint to add media to our company CMS, the body data seems to be ignored when sent through an axios post request or xhr post request. I do see a record added to the root folder of the CMS but it does not have the given name, tag, or file and it ignores the folderId entirely (because it goes to the root folder). When using postman with the same data, however, the post request works properly.
Steps I am following:
-
Create a FormData object to use as the data passed to the post request, like below:
const form = new FormData(); form.append('name', body.name); form.append('folderId', body.folderId); form.append('files', body.files); form.append('tags', body.tags);
-
Include the proper token for our CMS as part of the auth header and set content type as “multipart/form-data”
-
Call axios.post(url, form, config);
RESULT: 200 Success/OK response, record added to root folder with what looks like a UUID as a name, red X as file thumbnail, and no included tags.
Any thoughts or suggestions would be greatly appreciated!