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#?

3
  • i was talking about a web request here there it was about selecting files from command prompt right? Commented Aug 12, 2015 at 11:52
  • 1
    cURL is a command line utility. If you just mean a web request, take a look here: stackoverflow.com/questions/7688350/… Commented Aug 12, 2015 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 Commented Aug 12, 2015 at 12:09

2 Answers 2

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)

Sign up to request clarification or add additional context in comments.

Comments

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.