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

moondaddy 911 Reputation points
2020-12-07T21:47:09.883+00:00

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.

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,141 questions
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,247 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Yihui Sun-MSFT 801 Reputation points
    2020-12-08T06:20:30.11+00:00

    Hi @moondaddy ,

    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

    0 comments No comments