question

moondaddy-8531 avatar image
0 Votes"
moondaddy-8531 asked YihuiSun-MSFT answered

How to make a Ressults Key for an ASP.NET API call

I have a API that work but the client app calling is is getting an error and is looking for a results key.

Can someone please tell me how to add this to the API?

I'm using Visual Studio 2019 and this is a ASP.NET API project (not core).

Thank you.

dotnet-aspnet-core-generaldotnet-aspnet-general
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

YihuiSun-MSFT avatar image
0 Votes"
YihuiSun-MSFT answered

Hi @moondaddy-8531,

but the client app calling is is getting an error and is looking for a results key

  1. What is the error you encountered?Is it a 401 error?

  2. Did you enable authentication in WebAPI?

    1. If you use authentication in WebAPI, then when you send a request from the client, you need an authorization request header with credentials.

    2. Do you want to send API Key from the client?If this is the case, you can write:

         $.ajax({
                 type: 'GET',
                 url: 'xxxxxx',
                 headers: {
                   "APIKey":"APIKeyValue"
                 }
         });
      

       var client = new HttpClient();
       client.DefaultRequestHeaders.Add("APIKey", "APIKeyValue");
      

If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

Best Regards,
YihuiSun


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.