How to solve `Error getting remote image` in woocommerce rest api script?

admin2025-01-07  3

I'm using WooCommerce Rest API to upload images from another website using the img URLs. The script works well, but in 2 out of 10 websites I get this error:

{
  code: 'woocommerce_product_image_upload_error',
  message: 'Error getting remote image ?$pdpflexf2$&wid=440&hei=440. Error: Forbidden',
  data: { status: 400 }
}

I don't think I'm getting block as I can download it easily manually.

I'm using WooCommerce Rest API to upload images from another website using the img URLs. The script works well, but in 2 out of 10 websites I get this error:

{
  code: 'woocommerce_product_image_upload_error',
  message: 'Error getting remote image https://nb.scene7.com/is/image/NB/mt10sb_nb_02_i?$pdpflexf2$&wid=440&hei=440. Error: Forbidden',
  data: { status: 400 }
}

I don't think I'm getting block as I can download it easily manually.

Share Improve this question asked Nov 12, 2020 at 8:09 yoni349yoni349 11 bronze badge 4
  • Do you have access to the remote server logs? It says 'Forbidden' in the message, so the remote server is blocking you, yes. Why? You'd have to ask the server admin. (Unless the 'status: 400' is the actual response you're getting from the remote server in your script? 400 = Bad Request not Forbidden.) – Rup Commented Nov 12, 2020 at 14:10
  • @Rup, I dont have access...it's New Balance shoe website. So for sure, he is blocking me? I wonder why they would block their product pictures download. – yoni349 Commented Nov 12, 2020 at 14:27
  • Maybe they've set up a rate limit. Can you change your script to wait a few seconds and try again, e.g. up to three retries? – Rup Commented Nov 12, 2020 at 14:29
  • Websites do sometimes block user agents that look like common scrapers, or don't look like common browsers. But if you can download 8/10 shoe pictures from them correctly then I'd guess it's not that. – Rup Commented Nov 12, 2020 at 14:29
Add a comment  | 

1 Answer 1

Reset to default 0

API will not allow url with '?' as it can be dynamic and has security issue.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736254208a186.html

最新回复(0)