question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] ErrorResponseException / InsufficientAuthorization when specifying more than one 'responseFilter' value for Microsoft.Azure.CognitiveServices.Search.WebSearch Search

See original GitHub issue

Describe the bug When using the Microsoft.Azure.CognitiveServices.Search.WebSearch.WebSearchClient of the Microsoft.Azure.CognitiveServices.Search.WebSearch v2.0 NuGet package I can either specify no or one responseFilter value, however - since it is a List<string> parameter type and its documentation states I can provide a list of response types I want to get, I tried just that - more than one (i.e. three as shown in the example below), but when making the call I get an Microsoft.Azure.CognitiveServices.Search.WebSearch.Models.ErrorResponseException back stating that

Operation returned an invalid status code 'Forbidden'
Only these values are allowed: Webpages,Images,Videos,News,SpellSuggestions,entities,places,RelatedSearches,Computation,TimeZone,Translations
Microsoft.Azure.CognitiveServices.Search.WebSearch.Models.ErrorResponseException: Operation returned an invalid status code 'Forbidden'
   at Microsoft.Azure.CognitiveServices.Search.WebSearch.Web.SearchWithHttpMessagesAsync(String query, String acceptLanguage, String pragma, String userAgent, String clientId, String clientIp, String location, Nullable`1 answerCount, String countryCode, Nullable`1 count, String freshness, String market, Nullable`1 offset, IList`1 promote, IList`1 responseFilter, String safeSearch, String setLang, Nullable`1 textDecorations, String textFormat, Dictionary`2 customHeaders, CancellationToken cancellationToken)
   at Microsoft.Azure.CognitiveServices.Search.WebSearch.WebExtensions.SearchAsync(IWeb operations, String query, String acceptLanguage, String pragma, String userAgent, String clientId, String clientIp, String location, Nullable`1 answerCount, String countryCode, Nullable`1 count, String freshness, String market, Nullable`1 offset, IList`1 promote, IList`1 responseFilter, String safeSearch, String setLang, Nullable`1 textDecorations, String textFormat, CancellationToken cancellationToken)
   at AzureCognitiveSearch.Program.Main(String[] args) in D:\Development\Playground\AzureCognitiveSearch\AzureCognitiveSearch\Program.cs:line 63

See also: image

However, my input responseFilter values are part of the list of allowed values.

Expected behavior Search returns results for the given responseFilter values

Actual behavior (include Exception or Stack Trace)

Operation returned an invalid status code 'Forbidden'
Only these values are allowed: Webpages,Images,Videos,News,SpellSuggestions,entities,places,RelatedSearches,Computation,TimeZone,Translations
Microsoft.Azure.CognitiveServices.Search.WebSearch.Models.ErrorResponseException: Operation returned an invalid status code 'Forbidden'
   at Microsoft.Azure.CognitiveServices.Search.WebSearch.Web.SearchWithHttpMessagesAsync(String query, String acceptLanguage, String pragma, String userAgent, String clientId, String clientIp, String location, Nullable`1 answerCount, String countryCode, Nullable`1 count, String freshness, String market, Nullable`1 offset, IList`1 promote, IList`1 responseFilter, String safeSearch, String setLang, Nullable`1 textDecorations, String textFormat, Dictionary`2 customHeaders, CancellationToken cancellationToken)
   at Microsoft.Azure.CognitiveServices.Search.WebSearch.WebExtensions.SearchAsync(IWeb operations, String query, String acceptLanguage, String pragma, String userAgent, String clientId, String clientIp, String location, Nullable`1 answerCount, String countryCode, Nullable`1 count, String freshness, String market, Nullable`1 offset, IList`1 promote, IList`1 responseFilter, String safeSearch, String setLang, Nullable`1 textDecorations, String textFormat, CancellationToken cancellationToken)
   at AzureCognitiveSearch.Program.Main(String[] args) in D:\Development\Playground\AzureCognitiveSearch\AzureCognitiveSearch\Program.cs:line 63

To Reproduce Steps to reproduce the behavior (include a code snippet, screenshot, or any additional information that might help us reproduce the issue)

Run the following repro code:

try
{
    var webSearchResponse = await new WebSearchClient(new ApiKeyServiceClientCredentials("Your API KEY HERE"))
        .Web
        .SearchAsync(
            query: "COVID-19 Statistik Erlangen",
            count: 50,
            offset: 0,
            market: "de-DE",
            setLang: "DE",
            //countryCode:
            safeSearch: SafeSearch.Off,
            location: $"lat:49.583332;long:11.016667;re:22;disp:Erlangen, Germany", // see https://docs.microsoft.com/en-us/rest/api/cognitiveservices-bingsearch/bing-web-api-v7-reference
            responseFilter: new List<string>()
            {
                "WebPages",
                "RelatedSearches",
                "SpellSuggestions"
            });

}
catch (Exception ex)
{
    Console.WriteLine("ex.Message);
}

Environment:

  • Name and version of the Library package used: Microsoft.Azure.CognitiveServices.Search.WebSearch 2.0
  • Hosting platform or OS and .NET runtime version: Windows 10 .NET Core 3.1
  • IDE and version : Visual Studio 16.7

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jsquirecommented, Aug 10, 2020

Thank you for your feedback. Tagging and routing to the team best able to assist.

0reactions
joergbattermanncommented, Nov 1, 2021

This issue can still be reproduced as originally reported @KranthiPakala-MSFT.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Indexer errors and warnings - Azure Cognitive Search
This link will often point to one of the below sections on this page. https://go.microsoft.com/fwlink/?linkid=2106475. Error: Could not read ...
Read more >
Indexer troubleshooting guidance - Azure Cognitive Search
In this article. Troubleshoot connections to restricted resources; Azure SQL Database serverless indexing (error code 40613); Azure Active ...
Read more >
HTTP status codes - Azure Cognitive Search
The response body contains an error message explaining what the specific problem is. 403 Forbidden, Returned when you pass an invalid api-key.
Read more >
Filters in Azure Cognitive Search
You can specify one filter for each search operation, but the filter itself can include multiple fields, multiple criteria, and if you use ......
Read more >
Return a semantic answer - Azure Cognitive Search
It consists of one or more verbatim passages from a search document, formulated as an answer to a query that looks like a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found