Marklogic 400错误请求

编程入门 行业动态 更新时间:2024-10-09 23:21:17
本文介绍了Marklogic 400错误请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我试图按照此处所述在REST Uri中使用StructuredQuery . 当我在Chrome中使用Postman并以以下方式请求查询URI时:

I trying to use StructuredQuery in REST Uri as documented here. When I use Postman from Chrome and requesting query URI as:

IPADDRESS:PORT/v1/search?structuredQuery={"query":{"or-query":{"queries":[{"and-query":{"queries":[ {"word-constraint-query":{"constraint-name":"bio","text":["product"]}}, {"value-constraint-query":{"constraint-name":"company","text":["MarkLogic"]}} ]}}, {"and-query":{"queries":[ {"element-constraint-query":{"constraint-name":"spoken","and-query": {"queries":[{"term-query":{"text":["fie"]}}]} }}, {"word-constraint-query":{"constraint-name":"stagedir","text":["fall"]}}, {"value-constraint-query":{"constraint-name":"person","text":["GRUMIO"]}} ]}}, {"and-query":{"queries":[ {"properties-query":{"term-query":{"text":["fish"]}}}, {"directory-query":{"uri":["/images/2012/02/27/"]},"infinite":true} ]}}, {"and-query":{"queries":[ {"collection-query":{"uri":["mlw2012"]}}, {"term-query":{"text":["fun"]}} ]}}]}}}

给我答复.

现在,当我尝试使用Java来实现此功能时,使用HttpClient会给我400错误的请求错误,代码:

Now when I try to implement this in Java, using HttpClient it's giving me 400 Bad request error, Code:

CredentialsProvider credsProvider = new BasicCredentialsProvider(); query="192.168.192.110:8013/v1/search?structuredQuery=%7B%22query%22%3A%7B%22or-query%22%3A%7B%22queries%22%3A%5B%7B%22and-query%22%3A%7B%22queries%22%3A%5B%20%7B%22word-constraint-query%22%3A%7B%22constraint-name%22%3A%22bio%22%2C%22text%22%3A%5B%22product%22%5D%7D%7D%2C%20%7B%22value-constraint-query%22%3A%7B%22constraint-name%22%3A%22company%22%2C%22text%22%3A%5B%22MarkLogic%22%5D%7D%7D%20%5D%7D%7D%2C%20%7B%22and-query%22%3A%7B%22queries%22%3A%5B%20%7B%22element-constraint-query%22%3A%7B%22constraint-name%22%3A%22spoken%22%2C%22and-query%22%3A%20%7B%22queries%22%3A%5B%7B%22term-query%22%3A%7B%22text%22%3A%5B%22fie%22%5D%7D%7D%5D%7D%20%7D%7D%2C%20%7B%22word-constraint-query%22%3A%7B%22constraint-name%22%3A%22stagedir%22%2C%22text%22%3A%5B%22fall%22%5D%7D%7D%2C%20%7B%22value-constraint-query%22%3A%7B%22constraint-name%22%3A%22person%22%2C%22text%22%3A%5B%22GRUMIO%22%5D%7D%7D%20%5D%7D%7D%2C%20%7B%22and-query%22%3A%7B%22queries%22%3A%5B%20%7B%22properties-query%22%3A%7B%22term-query%22%3A%7B%22text%22%3A%5B%22fish%22%5D%7D%7D%7D%2C%20%7B%22directory-query%22%3A%7B%22uri%22%3A%5B%22%2Fimages%2F2012%2F02%2F27%2F%22%5D%7D%2C%22infinite%22%3Atrue%7D%20%5D%7D%7D%2C%20%7B%22and-query%22%3A%7B%22queries%22%3A%5B%20%7B%22collection-query%22%3A%7B%22uri%22%3A%5B%22mlw2012%22%5D%7D%7D%2C%20%7B%22term-query%22%3A%7B%22text%22%3A%5B%22fun%22%5D%7D%7D%20%5D%7D%7D%5D%7D%7D%7D" credsProvider.setCredentials(new AuthScope(IpAddress, port), new UsernamePasswordCredentials(user, password)); DefaultHttpClient client = new DefaultHttpClient(); client.setCredentialsProvider(credsProvider); HttpGet get = new HttpGet(query); ResponseHandler<String> handler = new BasicResponseHandler(); HttpResponse resp = client.execute(get);

错误:

HTTP/1.1 400 Bad Request [Content-type: application/xml, Server: MarkLogic, Content-Length: 364, Connection: Keep-Alive, Keep-Alive: timeout=5]

我想念什么?

在此先感谢, Prithvi.

Thanks in advance, Prithvi.

推荐答案

如果打印出错误响应的正文,应该会给您更多信息.

If you print out the body of the error response, that should give you more information.

也就是说,您可能要考虑使用Java API,该Java API建立在Apache HttpClient和Jersey客户端之上,并为您处理HTTP交互.

That said, you might want to consider using the Java API, which is built on top of Apache HttpClient and Jersey Client and handles the HTTP interactions for you.

更多推荐

Marklogic 400错误请求

本文发布于:2023-10-10 17:54:59,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1479317.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   Marklogic

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!