Support » Fixing WordPress » WP API v2 image upload from media endpoint Invalid file type.

Viewing 10 replies - 1 through 10 (of 10 total)
  • I see a difference in the content type. In Postman you seem to have specified image/jpeg, but it should be multipart/form-data.

    Can you also show a screenshot of the response?

    Thread Starter azharrahim

    (@azharrahim)

    @threadi will please share the steps to upload images with postman using the image link or from local path.Thanks

    Simply stating that is quite enough for me:
    https://imgur.com/a/PZCrEbz
    At Authorization you have to enter the Basic Auth of course.

    Double, sorry 😀

    • This reply was modified 1 week, 3 days ago by threadi.
    Thread Starter azharrahim

    (@azharrahim)

    This is what I get
    https://snipboard.io/xrbPcl.jpg

    You have not entered an authorization.
    And you use an absolute path to transfer file. I have selected the file. Thus postman loads the necessary header information for me from the file.

    Thread Starter azharrahim

    (@azharrahim)

    I add the authorization already after uploading this way getting the same issue no blank image this is what I get

    {
        "id": 2244,
        "date": "2022-11-27T12:08:32",
        "date_gmt": "2022-11-27T12:08:32",
        "guid": {
            "rendered": "https://bdavey.co/wp-content/uploads/2022/11/file-mmo-3.png",
            "raw": "https://bdavey.co/wp-content/uploads/2022/11/file-mmo-3.png"
        },
        "modified": "2022-11-27T12:08:32",
        "modified_gmt": "2022-11-27T12:08:32",
        "slug": "file-mmo-3",
        "status": "inherit",
        "type": "attachment",
        "link": "https://bdavey.co/file-mmo-3/",
        "title": {
            "raw": "file-mmo-3",
            "rendered": "file-mmo-3"
        },
        "author": 1,
        "comment_status": "open",
        "ping_status": "closed",
        "template": "",
        "meta": [],
        "permalink_template": "https://bdavey.co/?attachment_id=2244",
        "generated_slug": "file-mmo-3",
        "description": {
            "raw": "",
            "rendered": "<p class=\"attachment\"><a href='https://bdavey.co/wp-content/uploads/2022/11/file-mmo-3.png'><img width=\"1\" height=\"1\" src=\"https://bdavey.co/wp-content/uploads/2022/11/file-mmo-3.png\" class=\"attachment-medium size-medium\" alt=\"\" decoding=\"async\" loading=\"lazy\" /></a></p>\n"
        },
        "caption": {
            "raw": "",
            "rendered": ""
        },
        "alt_text": "",
        "media_type": "image",
        "mime_type": "image/png",
        "media_details": {
            "filesize": 23340,
            "sizes": {}
        },
        "post": null,
        "source_url": "https://bdavey.co/wp-content/uploads/2022/11/file-mmo-3.png",
        "missing_image_sizes": [],
        "_links": {
            "self": [
                {
                    "href": "https://bdavey.co/wp-json/wp/v2/media/2244"
                }
            ],
            "collection": [
                {
                    "href": "https://bdavey.co/wp-json/wp/v2/media"
                }
            ],
            "about": [
                {
                    "href": "https://bdavey.co/wp-json/wp/v2/types/attachment"
                }
            ],
            "author": [
                {
                    "embeddable": true,
                    "href": "https://bdavey.co/wp-json/wp/v2/users/1"
                }
            ],
            "replies": [
                {
                    "embeddable": true,
                    "href": "https://bdavey.co/wp-json/wp/v2/comments?post=2244"
                }
            ],
            "wp:action-unfiltered-html": [
                {
                    "href": "https://bdavey.co/wp-json/wp/v2/media/2244"
                }
            ],
            "wp:action-assign-author": [
                {
                    "href": "https://bdavey.co/wp-json/wp/v2/media/2244"
                }
            ],
            "curies": [
                {
                    "name": "wp",
                    "href": "https://api.w.org/{rel}",
                    "templated": true
                }
            ]
        }
    }

    same issue blank image
    https://snipboard.io/Ki7Rzm.jpg

    With this return, the API confirms that it has successfully saved the image. Why then the image generation does not work could be due to many other things. Also plugins or the theme you are using. Or missing PHP libraries.

    Thread Starter azharrahim

    (@azharrahim)

    Can you now give me a source page where I can see the step-by-step guide?

    I’m not sure what aspect of your plan you are referring to. Since the API offers an enormous amount of possibilities, there is no step-by-step guide. In any case, the first place to go is the manual for the API here: https://developer.wordpress.org/rest-api/

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