Sending a Solr query url in SolrNet - c#

I have a certain url representing a Solr request which I would like to send with SolrNet. The url contains the request handler name and some other parameters such as a stream.url. How do I generate the request using SolrNet and send it to Solr?
Please illustrate the way to do it with a concrete request. For example: http://localhost:8983/solr/mlt?stream.url=http://lucene.apache.org/solr/&mlt.fl=manu,cat&mlt.interestingTerms=list&mlt.mintf=0. Namely, how do I specify in C# code which request handler to use, how do I instantiate all the GET parameters in the above url, and finally, how do I execute the query?

You need to reference the SolrNet Wiki Documentation, specifically the following:
Mapping
Initialization
Querying
More Like This
For additional parameters that are not included directly in SolrNet, see the "Additional Parameters" section at the Querying link above.
Please look through this information and come back if you have any issues setting things up or executing a query.

Related

OData request about metadata

I had followed the tutorial about, how to create OData endpoint on the page http://www.asp.net/web-api/overview/odata-support-in-aspnet-web-api/odata-v4/create-an-odata-v4-endpoint.
It works as expected
The request about metadata, it works as expected to:
When I make a request to url http://localhost:21937/Products, then I've got all entries from products
My questions are:
What is the rootservice of this?
How can I query the ressource types like
ResourceTypes('Namespace.Product')
Not sure what you mean root service, but if you mean how to route a call to an action of controller, in this sample, OData Web API routing conversion is been used, and more detail can refer to http://odata.github.io/WebApi/#03-02-built-in-routing-conventions
If you mean the type information, the you can query http://localhost:21937/$metadata

Restful PUT acting as GET when testing

So I've been working on an api that, using RESTful, allows the user to get data from a database. Pretty simple, URL is along the lines of local:port/projects/[id of project]. The api returns some xml with 4 or 5 results.
What I'm having trouble with is PUT. As far as I understand it, I should use the same url, but use the PUT request method, and include the data that I want sent in a parameter. The problem seems to be that when I run the PUT, it just returns the same data as a GET.
I'm using the following site to test this: wst dot mytechlabs dot com (won't let me post two links here;?)
The code for my controller is located here: http://pastebin.com/3HXXR4YY
Thanks in advance, I'll monitor this, so let me know if I forgot any info that would help.

how to get the project specific jira issues using jira rest api in .net?

I have a requirement where i need to get all the issues for a particular project in jira so for this i have created a console application which has rest client class using which I make a GET request call and for testing purpose rest api url is
"https://jira.atlassian.com/rest/api/latest/issue/JRA-9"
using this url i make a HttpWebRequest and get the response back in json formated string. Now this json string contain all the issue specific information but my actual requrement is to get all the project specific issues.
I tried to find out if i get any project specifc URL for testing purpose from where i get json reply back and I found http://kelpie9:8081/rest/api/2/search?jql=project=QA+order+by+duedate&fields=id,key but for this i get the "The remote name could not be resolved: 'kelpie9'" error.
Could you please help me in this?
`
JIRA's REST API does not appear to currently support any project-based queries separate from their search API.
You can specify a specific project in the search by using the JQL. Given that you know a project (e.g., "JRA" in "JRA-9"), then you can quickly search through all of its issues:
Working result: https://jira.atlassian.com/rest/api/latest/search?jql=project=JRA
One important note is that the results return actual total versus what is actually returned:
"startAt":0,"maxResults":50,"total":30177
You can add query string variables to the request to get more (or less) results. You can also control the fields related to issues to retrieve as well: https://jira.atlassian.com/rest/api/latest/search?jql=project=JRA&startAt=75&maxResults=75 (slower the more you request, and probably not nice to hit their public servers with big numbers).
You can even POST a JSON object that represents the query (slightly tweaked from the linked search docs):
{"jql":"project = JRA","startAt":75,"maxResults":75,"fields":["id","key"]}
Of interest, and as part of the JQL, you can sort the results by any field. Just add " order by id" to the project name, as-in "jql=JRA+order+by+id" in the querystring or "jql": "project = JRA order by id" in the POSTed JSON body.
Note: Above is the actual answer to the real question. However, the literal question is the cause of the `The remote name could not be resolved: 'kelpie9' error.
Their documentation shows kelpie9 as an example server name that they are testing on internally, running on port 8081. Your computer is not aware of a server/machine named kelpie9, as it does not publicly exist. Replace kelpie9 with whatever your JIRA server's hostname is internally and 8081 with whatever port it is using (or remove it if you do not see one when you view JIRA on your intranet site, which means port 80 for http and port 443 for https). For example, many companies run it a "https://jira/". You would replace the example link with https://jira/rest/api/2/search?jql=project=QA+order+by+duedate&fields=id,key.

Unable to pass a URL in GET request to a RESTful web service in C#

I am stuck at an unexpected issue in my project. The issue is that there is a URL produced on the fly in my code that I have to submit it to a RESTful web service via a GET request. For e.g. the URL to submit looks like this: http://mysampleserver.com:8080/calc/8999/bpaX
The RESTful server accepts URL as its last parameter in the format below:
http://myRestfulAPI.domainname.com/capture/bbbb/http://mysampleserver.com:8080/calc/8999/bpaX
I also used System.Net.HttpUtility.UrlEncode(....) to encode the "URL to submit" first to incorporate it in the RESTful service call.
That resulted in getting the error below:
System.Web.HttpException: A potentially dangerous Request.Path value was detected from the client (:)
To try to resolve it, I followed the steps described per this web page but no luck.
I am using MVC 4 to implement the RESTful API in C#.
Any clue or idea how to get around this showstopper issue?
There are at least two solutions I can think of.
Change your RESTFul service to use post, because you send information to your server, and potentially it will change your resource status, based on HTTP protocol , you should use POST anyway.
You can also encode your url with Base64
The steps that you've tried are the correct steps. See also this question potentially dangerous... which is the same issue.
There are a number of characters that .NET doesn't allow in in a URL by default, and the : is one of them (as a query string, at least). They are 'potentially dangerous'. Making this change to the configuration file allows these characters to be passed through to your application.
You need to Url.Encode the url in the query string (mvc parameters) otherwise it is interpreted as more URL encoding for MVC to decode as parameters. Try something like #Url.Encode(yourStringObject) and pass it as the last value or as a query (i.e. &q=url)

WCF 5 - OData 3 using POST

I have a WFC Data Service using OData v3. Following REST specification I created a method invoked by POST that adds an entity (a Client in this case) using Entity Framework.
Everything works great and adds as expected but the thing is I'm not pretty comfortable passing all the parameters I need using the query string, meaning the "typical" POST is usually application/x-www-form-urlencoded and sends the parameters in the request body instead of the query string. WCF Data Services don't seem to allow this in a relatively straightforward way.
Are there any major drawback/security issue (besides the obvious size limitation of the query string) using the query string that I should know of? Can I send parameters in the request body and use application/x-www-form-urlencoded without jumping through millions of hoops?
It just doesn't feel right to use the query string for everything.
The standard way of creating entities using OData is to send a POST to the entity set URL (of the entity set you want the entity to insert into). That POST has the entity in its body either as ATOM or JSON payload. http://www.odata.org/documentation/operations#CreatingnewEntries
Using service operations to create new entities is definitely possible, but it's not that common. It's currently not possible to send the parameters to the service operation inside a body (without some serious hacking).

Categories

Resources