[英]Docker Jenkins Image - curl: (3) Illegal characters found in URL
[英]curl: (3) unmatched brace in URL position 1:
我正在從這里運行 Apache Solr 教程:
http://lucene.apache.org/solr/guide/7_6/solr-tutorial.html
Solr 正在運行,我可以在 Web 瀏覽器中運行查詢。
該教程提到了我不熟悉的cURL
。
我已將CURL
壓縮到C:\\Curl
並將C:\\Curl
包含在PATH environment variable
: C:\\Curl\\curl-7.63.0-win64-mingw\\bin
在 Windows 命令提示符下運行以下命令時出現錯誤。 我用谷歌搜索試圖找到一個無濟於事的解決方案:
代碼如下:
C:\Curl\curl-7.63.0-win64-mingw\bin>curl -X POST -H 'Content-type:application/json' --data-binary '{"add-field": {"name":"name", "type":"text_general", "multiValued":false, "stored":true}}' http://localhost:8983/solr/films/schema
產生以下錯誤:
curl: (3) unmatched brace in URL position 1:
{name:name,
^
curl: (3) URL using bad/illegal format or missing URL
curl: (3) URL using bad/illegal format or missing URL
curl: (3) unmatched close brace/bracket in URL position 12:
stored:true}}'
^
{
"responseHeader":{
"status":400,
"QTime":1},
"error":{
"metadata":[
"error-class","org.apache.solr.common.SolrException",
"root-error-class","org.apache.solr.common.SolrException"],
"msg":"no stream",
"code":400}}
我嘗試添加-g
來關閉通配符。
curl -g -X POST -H 'Content-type:application/json' --data-binary '{"add-field": {"name":"name", "type":"text_general", "multiValued":false, "stored":true}}' http://localhost:8983/solr/films/schema
這產生了幾乎相同的錯誤:
C:\Curl\curl-7.63.0-win64-mingw\bin>curl -g -X POST -H 'Content-type:application/json' --data-binary '{"add-field": {"name":"name", "type":"text_general", "multiValued":false, "stored":true}}' http://localhost:8983/solr/films/schema
curl: (3) URL using bad/illegal format or missing URL
curl: (3) URL using bad/illegal format or missing URL
curl: (3) URL using bad/illegal format or missing URL
curl: (3) URL using bad/illegal format or missing URL
{
"responseHeader":{
"status":400,
"QTime":1},
"error":{
"metadata":[
"error-class","org.apache.solr.common.SolrException",
"root-error-class","org.apache.solr.common.SolrException"],
"msg":"no stream",
"code":400}}
然后我嘗試刪除單引號並轉義雙引號,但隨后出現以下錯誤:
curl -g -X POST -H Content-type:application/json --data-binary {\"add-field\": {\"name\":\"name\", \"type\":\"text_general\", \"multiValued\":false, \"stored\":true}} http://localhost:8983/solr/films/schema
curl:(3) URL 使用錯誤/非法格式或缺少 URL curl:(3) URL 使用錯誤/非法格式或缺少 URL curl:(3) URL 使用錯誤/非法格式或缺少 URL curl:(3) URL 使用錯誤/ 非法格式或缺少 URL { "responseHeader":{ "status":500, "QTime":4}, "error":{ "msg":"Premature EOF: char=(EOF),position=11 AFTER=' '", "trace":"org.noggit.JSONParser$ParseException: Premature EOF: char=(EOF),position=11 AFTER=''\\r\\n\\tat org.noggit.JSONParser.err(JSONParser.java: 419)\\r\\n\\tat org.noggit.JSONParser.next(JSONParser.j ava:973)\\r\\n\\tat org.noggit.JSONParser.nextEvent(JSONParser.java:1061)\\r\\n\\tat org .apache.solr.common.util.CommandOperation.parse(CommandOperation.java:285)\\r\\n\\tat org.apache.solr.common.util.Command Operation.readCommands(CommandOperation.java:350)\\r\\n \\tat org.apache.solr.common.util.CommandOperation.readCommands(CommandOperation.java:326)\\r\\n\\tat org.apache.solr.api.ApiBag.getCommandOperations(A piBag.java:289)\\r\\ n\\tat org.apache.solr.servlet.HttpSolrCall.getCommands (HttpSolrCall.java:1073)\\r\\n\\tat org.apache.solr.servlet.SolrRequestParsers$1.getCommands(SolrRequestParsers.java:245)\\r\\n\\tat o rg.apache.solr.schema.SchemaManager.performOperations (SchemaManager.java:77)\\r\\n\\tat org.apache.solr.handler.SchemaHandler.handleRequestBody(SchemaHandler.java:90)\\r\\n\\tat org.apache.solr.handler.Requ estHandlerBase.handleRequest( RequestHandlerBase.java:199)\\r\\n\\tat org.apache.solr.core.SolrCore.execute(SolrCore.java:2541)\\r\\n\\tat org.apache.solr.servlet.HttpSolrCall.execute(HttpSolrCall.execute(HttpSolrCall. java:709)\\r\\n\\tat org.apache.solr.servlet.HttpSolrCall.call(HttpSolrCall.java:515)\\r\\n\\tat org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:第 377 章:1634)\\r\\n\\tat org.eclipse.jetty.servlet.ServletHandler.doHa ndle(ServletHandler.java:533)\\r\\n\\tat org.eclipse.jetty.server.hand ler.ScopedHandler.handle(ScopedHandler.java:146)\\r\\n\\tat org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548)\\r\\n\\tat org.eclipse.jetty.server。 handler.HandlerWrapper.handle(HandlerWrapper.java:132)\\r\\n\\tat org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:257)\\r\\n\\tat org.eclipse.je tty .server.session.SessionHandler.doHandle(SessionHandler.java:1595)\\r\\n\\tat org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255)\\r\\n\\tat org.eclipse .jetty.server.handler。 ContextHandler.doHandle(ContextHandler.java:1317)\\r\\n\\tat org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:203)\\r\\n\\tat org.eclipse.jetty.servlet。 ServletHandler.doScope(Serv letHandler.java:473)\\r\\n\\tat org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1564)\\r\\n\\tat org.eclipse.jetty.server .handler.ScopedHandler.nextScope(ScopedHandler.java:201)\\r\\n\\tat org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1219)\\r\\n\\tat org.eclipse.jetty .server.handler.ScopedHandler.handle(ScopedHandler.java:144)\\r\\n\\tat org.eclipse.jett y.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:219)\\r\\n\\tat org. eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:126)\\r\\n\\tat org.eclipse.je tty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)\\r\\n\\ tat org.eclipse.jetty.rewrite.handler.RewriteHandler.handle(RewriteHandler.java:335)\\r\\n\\tat org.eclipse.jetty.server.handler。 處理 lerWrapper.handle(HandlerWrapper.java:132)\\r\\n\\tat org.eclipse.jetty.server.Server.handle(Server.java:531)\\r\\n\\tat org.eclipse.jetty.server.HttpChannel .handle(HttpChannel.java:352)\\r\\n\\tat org.eclipse .jetty.server.HttpConnection.onFillable(HttpConnection.java:260)\\r\\n\\tat org.eclipse.jetty.io.AbstractConnection$ReadCallback .succeeded(AbstractConnection.java:281)\\r\\n\\tat org.eclipse.jetty.io.FillIn terest.fillable(FillInterest.java:102)\\r\\n\\tat org.eclipse.jetty.io.ChannelEndPoint$2 .run(ChannelEndPoint.java:118)\\r\\n\\tat org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill .java:333)\\r\\n\\tat org.eclipse.jetty.util .thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310)\\r\\n\\tat org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java :168)\\r\\n\\tat org .eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:126)\\r\\n\\tat org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThread 執行者。 java:366)\\r\\n\\tat org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:762)\\r\\n\\tat org.eclipse.jetty.util.thread.QueuedThreadPool$2.run (QueuedThreadPool.java:680)\\r\\n\\tat java. lang.Thread.run(Unknown Source)\\r\\n", "code":500}}
我知道關於這個問題有很多類似的問答,但它們並不完全相同,我嘗試過的解決方案都沒有解決我的問題。
我用雙引號替換了單引號,並用反斜杠將花括號內的雙引號轉義了,並且有效。
我從這里出發:
curl --X POST -H 'Content-type:application/json' --data-binary '{"add-field": {"name":"name", "type":"text_general", "multiValued":false, "stored":true}}' http://localhost:8983/solr/films/schema
對此:
curl --X POST -H "Content-type:application/json" --data-binary "{\"add-field\": {\"name\":\"name\", \"type\":\"text_general\", \"multiValued\":false, \"stored\":true}}" http://localhost:8983/solr/films/schema
謝謝大家的集體回答。 我確信將JSON
添加到單獨的文件中可能會有一些JSON
,但是我想避免創建其他文件。
Windows命令提示符不支持單引號。 這是一個問題,因為cURL語句使用單引號指定JSON數據。
要解決此問題,請將JSON保存在一個單獨的文件(例如add-field.txt
)中,然后將其導入到cURL語句中,以便以后可以像這樣運行它:
curl -X POST -H 'Content-type:application/json' --data-binary @add-field.txt http://localhost:8983/solr/films/schema
我會走另一條路。 如果您安裝Microsoft的wonderfool工具WSL 。 您將能夠像在Linux系統中一樣運行所有這些命令。 最終將節省大量時間。
Gitbash 為我解決了它。 WSL 崩潰的原因我現在忽略了。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.