Services Plugins FAQs

Bing Image Search API Response Images CORS Issue

Hi,

We are not able to access the response images of the bing-image-search API and getting a cors error from the browser, we have tried to set Licence public as well.
Please find the error, request, and response below,

ERROR:
Access to image at ‘https://apparelmagazine.co.nz/supermarketnews/wp-content/uploads/sites/2/2018/03/APPLES-4.jpg’ from origin ‘https://web.dotpe.in’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.

REQUEST:
curl --location --request GET ‘https://api.cognitive.microsoft.com/bing/v7.0/images/search?q=apple&size=Large&maxFileSize=10000000&imageType=Photo&count=21&offset=0&mkt=en-in&safeSearch=Moderate&key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
–header ‘Ocp-Apim-Subscription-Key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx’

RESPONSE:
{
“_type”: “Images”,
“instrumentation”: {
“_type”: “ResponseInstrumentation”
},
“readLink”: “https://api.cognitive.microsoft.com/api/v7/images/search?q=apple”,
“webSearchUrl”: “apple - Bing images”,
“queryContext”: {
“originalQuery”: “apple”,
“alterationDisplayQuery”: “apple”,
“alterationOverrideQuery”: “+apple”,
“alterationMethod”: “AM_JustChangeIt”,
“alterationType”: “CombinedAlterationsChained”
},
“totalEstimatedMatches”: 1000,
“nextOffset”: 21,
“currentOffset”: 0,
“value”: [
{
“webSearchUrl”: “apple - Bing”,
“name”: “JAPAN PREPARES TO ENJOY AN APPLE A DAY | Supermarket News”,
“thumbnailUrl”: “https://tse1.mm.bing.net/th?id=OIP.4YZsMxAGjBMkjc5ZvQk0ZAHaE8&pid=Api”,
“datePublished”: “2020-05-19T14:23:00.0000000Z”,
“isFamilyFriendly”: true,
“contentUrl”: “http://apparelmagazine.co.nz/supermarketnews/wp-content/uploads/sites/2/2018/03/APPLES-4.jpg”,
“hostPageUrl”: “http://supermarketnews.co.nz/japan-prepares-to-enjoy-an-apple-a-day/”,
“contentSize”: “723250 B”,
“encodingFormat”: “jpeg”,
“hostPageDisplayUrl”: “supermarketnews.co.nz/japan-prepares-to-enjoy-an-apple-a-day”,
“width”: 4000,
“height”: 2667,
“hostPageDiscoveredDate”: “2018-03-22T00:00:00.0000000Z”,
“thumbnail”: {
“width”: 474,
“height”: 316
},
“imageInsightsToken”: “ccid_4YZsMxAGcp_7E0DC574604858995E9E31AEAFFC7306mid_E317852317DF4CB1C0DA8D7D04E8B9F0F515E1E7simid_608004465496246192thid_OIP.4YZsMxAGjBMkjc5ZvQk0ZAHaE8”,
“insightsMetadata”: {
“pagesIncludingCount”: 2,
“availableSizesCount”: 2
},
“imageId”: “E317852317DF4CB1C0DA8D7D04E8B9F0F515E1E7”,
“accentColor”: “C53306”
}
],
“relatedSearches”: [
{
“text”: “Apple iPhone”,
“displayText”: “Apple iPhone”,
“webSearchUrl”: “Apple iPhone - Bing images”,
“searchLink”: “https://api.cognitive.microsoft.com/api/v7/images/search?q=Apple+iPhone”,
“thumbnail”: {
“thumbnailUrl”: “https://tse4.mm.bing.net/th?q=Apple+iPhone&pid=Api&mkt=en-IN&cc=IN&setlang=en&adlt=moderate&t=1
}
}
]
}

Thanks
Abhishek Sharma

Hello @abhishek.sharma1

Thanks for reaching out.

Please can you provide more details on when you get this error? I would appreciate if you would be able to provide the exact steps you took to get the error and any information that will help us to reproduce the issue on our side. We would be able to understand your issue better and resolve your issue faster if you can provide us with:

  • a detailed description of the issue you have

  • steps to reproduce your issue

  • screenshots and/or screencast of the issue you have (debugger, browser console, etc);

  • screenshots and/or screencasts of your setup

Looking forward to your reply!