Support » Developing with WordPress » Using the media API

  • Hi,

    I am trying to upload a base64 encoded string with the API. Either the documentation is incomplete ( or I missed something as to where the content is supposed to go. I came across this issue report on Github but that didn’t help me further.

    I am making a POST request, in which I get a 201 response, which should mean it was created. And using the filemanager/browser I can see that there is something created but the image is broken/not working. Below is a sample of my JS code.

                                url: wpApiSettings.root + wpApiSettings.versionString + 'media',
                                method: 'POST',
                                beforeSend: function (xhr) {
                                    xhr.setRequestHeader('X-WP-Nonce', wpApiSettings.nonce);
                                    xhr.setRequestHeader('Content-Type', 'image/jpeg');
                                    xhr.setRequestHeader('Content-Disposition', 'attachment;filename=image_1.jpeg');
                                data: {
    • This topic was modified 4 months, 1 week ago by  tuim. Reason: Added clarification

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • You haven’t actually described the problem you’re having. What’s the request you’re trying and what’s the response you get?

    You are right, I have a added a clarification and some code I am using.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.