Renganatha Arunachalam
Renganatha Arunachalam

Reputation: 349

How to Call this API (an ASP.NET WebAPI action)?

How to call the API which I will mention below? How to assign a value to requestMessage inside the argument?

    [Route("api/studies")]
    public IEnumerable<Dictionary<string, object>> GetStudies(HttpRequestMessage requestMessage)
    {
        var query = QueryParser.Parse(requestMessage.RequestUri);
        var response = _studyQuery.Execute(query);
        return response;
    }

Upvotes: 0

Views: 68

Answers (1)

arodriguezdonaire
arodriguezdonaire

Reputation: 5573

With your information we only can know that you need to put your request in a HttpRequestMessage object (https://msdn.microsoft.com/es-es/library/system.net.http.httprequestmessage%28v=vs.118%29.aspx) using this constructor

public HttpRequestMessage(HttpMethod method, string requestUri);

or this one

 public HttpRequestMessage(HttpMethod method, Uri requestUri);

so your code should be like this:

HttpRequestMessage httpRequestMessage(method, requestUri);
IEnumerable<Dictionary<string, object>> response = GetStudies(httpRequestMessage);

Can you give us more info about the API or something to know what kind of request you have to do?

Upvotes: 1

Related Questions