1

i want to get the data from elastic search using NEST but we are unable to write more consistent queries using nest. so i want to write a url and get the json data from the CURL command and use it building my UI. SO how can i do this using c#?

chinna2580
  • 2,065
  • 2
  • 16
  • 30
  • i was talking about a web request here there it was about selecting files from command prompt right? – chinna2580 Aug 12 '15 at 11:52
  • 1
    `cURL` is a command line utility. If you just mean a web request, take a look here: http://stackoverflow.com/questions/7688350/c-sharp-how-to-make-a-http-call – Rob Aug 12 '15 at 11:53
  • it is like i want to send the web request using the curl command to the elastic search and want to store the response – chinna2580 Aug 12 '15 at 12:09

2 Answers2

3

While it is a duplicate I wouldn't call out to another program just to hit a url.

Just use WebClient or WebRequest (difference)

Community
  • 1
  • 1
weston
  • 54,145
  • 21
  • 145
  • 203
1

curl is a linux tool to transfer data from & to servers through URLs.

elastic search is a full-text search engine with a RESTful web interface.

nest is a library that abstracts the REST api for you, if you say the abstractions do not fit your needs, you don't need to fall back to another command line program to query a REST server... if you're in a programming language that can do this easily and a lot more!

You can query REST server using C# just fine. This is the API spec: https://github.com/elastic/elasticsearch/tree/master/rest-api-spec

You can write your own REST webclient:

Create a URL request and then submit the request using HTTP GET or POST protocol . When the response data is returned, you must serialize the data against a set of data contracts. As REST Services add new functionality, these data contracts may need to be updated. A benefit of working with JSON serialization rather than XML serialization is that changes in the schema rarely cause issues for existing applications. For instance, if a new property is added to the REST Services, an application that uses the old data contracts can still process a response without errors; however, the new property will not be available. To get the new property, you must update the data contracts. In order to make use of JSON serialization in .NET, use the DataContractJsonSerializer by referencing the following libraries in your project:

  • System.Runtime.Serialization
  • System.ServiceModel.Web

Source: https://msdn.microsoft.com/en-GB/library/jj819168.aspx

Vincent De Smet
  • 4,859
  • 2
  • 34
  • 41