# loadImage() 403 Error

**URL:** <https://discourse.processing.org/t/loadimage-403-error/25734>\
**Category:** Coding Questions\
**Created:** [November 26, 2020, 5:37pm UTC](https://discourse.processing.org/t/loadimage-403-error/25734 "2020-11-26T17:37:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jorivdkolk](https://avatars.discourse-cdn.com/v4/letter/j/e9a140/32.png) [@jorivdkolk](https://discourse.processing.org/u/jorivdkolk)\
**Post date:** [November 26, 2020, 5:37pm UTC](https://discourse.processing.org/t/loadimage-403-error/25734/1 "2020-11-26T17:37:59Z")

</div>

I am trying to load an image from a URL. Some images work, but sometimes the response is a 403 error message. When I try to open the URL’s in my browser they work fine, but not through the processing code.  
One of the images that does not load is this one: [https://spoonacular.com/recipeImages/660290-556x370.jpg](https://spoonacular.com/recipeImages/660290-556x370.jpg)  
I looked into the http.request library, but I cannot find a way to open images with that.  
how can I solve this problem?

Thank you in advance!

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [November 26, 2020, 6:33pm UTC](https://discourse.processing.org/t/loadimage-403-error/25734/2 "2020-11-26T18:33:52Z")

</div>

This happens a lot when js or different styles are used on that specific website.  
A workaround is to publish it on Pinterest, and then right-click the image and copy the image link.  
Just as a test I have done that with your image.

```auto
PImage img; 

void setup() { 
  size(557, 370); 
  img = loadImage("https://i.pinimg.com/564x/bd/ed/ba/bdedba17d9ca1d047a8036b7587cea79.jpg"); 
  image(img, 0, 0);
}

```

---

<div class="post-metadata">

**Author:** ![jorivdkolk](https://avatars.discourse-cdn.com/v4/letter/j/e9a140/32.png) [@jorivdkolk](https://discourse.processing.org/u/jorivdkolk)\
**Post date:** [November 27, 2020, 8:30am UTC](https://discourse.processing.org/t/loadimage-403-error/25734/3 "2020-11-27T08:30:47Z")

</div>

Thank you for you anwser @noel!  
The link is provided by the Spoonacular Food API, and I need to open many of them through the code. So publishing every image on Pinterest is not really an option.  
Do you know how I could solve this issue through code? Is there a way to send the appropriate header for example with the request?

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [November 27, 2020, 8:51am UTC](https://discourse.processing.org/t/loadimage-403-error/25734/4 "2020-11-27T08:51:30Z")

</div>

> [@jorivdkolk](#):
>
> Do you know how I could solve this issue through code?

I’ve searched quite a bit some time ago, but have found no solution.

---

<div class="post-metadata">

**Author:** ![Glenton](https://avatars.discourse-cdn.com/v4/letter/g/8edcca/32.png) [@Glenton](https://discourse.processing.org/u/Glenton)\
**Post date:** [July 27, 2021, 4:31pm UTC](https://discourse.processing.org/t/loadimage-403-error/25734/5 "2021-07-27T16:31:36Z")

</div>

Hello,

I had the same problem as you with 403 error when trying to load image from an API.

Floflo gave me a solution today that solve my problem, maybe this can help you too:

> [@Using Headers for loading Images](https://discourse.processing.org/t/using-headers-for-loading-images/31450/7):
>
> Hey @Glenton I dont know if this helps: Its a little class which downloads an Image and then loads it via loadImage() from processing 
> 
> > **Click to see the my Example**
> >
> > String URL = "https://img.discogs.com/UoDAnoi3Cbp\_JvOrz4CRgZBBSfg=/fit-in/600x592/filters:strip\_icc():format(jpeg):mode\_rgb():quality(90)/discogs-images/R-367084-1263095553.jpeg.jpg"; PImage img; void setup() { size(100, 100); //img = requestImage(URL);//not working //img = loadImage(URL);//not working DownloadImage…
