developing REST API with query param

Jul 6, 2015 at 10:46 AM

I wrote sample client server to understand C++ REST SDK.

I got one problem :
How can I create a REST API which provides query param at server side?

Appreciate your time and help.

Jul 6, 2015 at 9:26 PM
Hi Pooja,

I'm having trouble understanding your question. Are you trying to deal with query parameters on the client side making a request or on the server side receiving one? Regardless take a look at the http_request class. There are several methods for retrieving/setting request URI to send. This class can be used to construct a request to send with the http_client class. An instance of http_request is received as a parameter in the http_listener request handlers.

Jul 7, 2015 at 5:23 AM
Hi Steve,

Thanks for your reply.

I am having trouble on the server side.
I need to expose one REST API to my clients with query parameter.

I am listening on https://localhost:8080

I want to create a REST ful API so that client can call https://localhost:8080/search/q="searchString"

How we can achieve it using C++ REST SDK??

Jul 7, 2015 at 5:32 PM
Hi Pooja,

Ok so you have an http_listener on https://localhost:8080. When you receive a request an http_request object will be passed into the function object callback you registered with one of the support(...) methods. From the http_request class you access to the full request URI, including the query component. Specifically I believe you want to call http_request::request_uri().

Jul 13, 2015 at 7:43 AM
Hi Steve,

Thank you for the reply.