Skip to content

Mapping parameters #82

Answered by scottoffen
kevin5km asked this question in Q&A
Discussion options

You must be logged in to vote

Path parameters are different from the query string.

If you want the request id in the path parameter, your path should be /api/heartbeat/ab123, and you would use the your existing method, with a modification to the Route attribute:

[RestRoute("Get", "/api/heartbeat/{requestID}")]
public async Task Heartbeat(IHttpContext context)
{
    var requestID = context.Request.PathParameters["requestID"];
    await context.Response.SendResponseAsync(requestID).ConfigureAwait(false);
}

If you want the request id to be in the query string, you would use your existing path and query string of /api/heartbeat?requestID=ab123, but your Route attribute and method would change to:

[RestRoute("Get", "/api/h…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by scottoffen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants