# Edit image with Dall-E and React but gets error 415

**URL:** https://community.openai.com/t/edit-image-with-dall-e-and-react-but-gets-error-415/175757
**Category:** API
**Created:** [April 24, 2023, 1:21pm UTC](https://community.openai.com/t/edit-image-with-dall-e-and-react-but-gets-error-415/175757 "2023-04-24T13:21:46Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![artexploresmk](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/artexploresmk/32/32968_2.png) [@artexploresmk](https://community.openai.com/u/artexploresmk)
#### Post date: [April 24, 2023, 1:21pm UTC](https://community.openai.com/t/edit-image-with-dall-e-and-react-but-gets-error-415/175757/1 "2023-04-24T13:21:46Z")

</div>

I’m a trying to make a post request, where I sent an image with a mask (png from a local folder), but get the error 415. I now that 415 means an error with the media-type, but I can see I’m doing it wrong.

This is the image:

 ![test](https://us1.discourse-cdn.com/openai1/original/3X/c/6/c6504af385ca869bcb1916441fd2f6137b8072d6.png)

This is the doc I’m looking at: [OpenAI API](https://platform.openai.com/docs/api-reference/images/create-edit)

This is my code/function to make the request to Dall-E:

```auto
async function generateImage() {
    try {
      const imageUrl = "https://api.openai.com/v1/images/edits";

      const requestBody = JSON.stringify({
        image: "/test/test.png",
        prompt: "Make a background of bananas",
        n: 1,
        size: "512x512",
      });

      const response = await fetch(imageUrl, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          Authorization: `Bearer MY SECRET CODE`,
        },
        body: requestBody,
      });

      if (response.ok) {
        const responseData = await response.json();
        setResultImage(responseData.resultImage);
        console.log("response", responseData);
        stageRef.current = responseData.resultImage;
      } else {
        console.log("Failed to generate image", response.status);
      }
    } catch (error) {
      console.log(error);
    }
  }

```

Can anyone see what is wrong?  
I have asked ChatGPT as well, but nothing helped…

---

<div class="post-metadata">

### Author: ![EricGT](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/ericgt/32/20571_2.png) [@EricGT](https://community.openai.com/u/EricGT)
#### Post date: [December 17, 2023, 1:40pm UTC](https://community.openai.com/t/edit-image-with-dall-e-and-react-but-gets-error-415/175757/2 "2023-12-17T13:40:19Z")

</div>


