Couchdb illegal database name issue during replica

2019-09-10 05:59发布

I am trying to replicate a couchdb database using filters. This is my code that I am running using Command Prompt:

curl -H 'Content-Type: application/json' -X POST http://localhost:5984/_replicate -d '{"source": "http://localhost:5984/source_database", "target": "http://localhost:5984/testdb", "create_target": true, "continuous": true, "doc_ids": ["000803f8-7f61-4afd-b532-8e6c1028d965"]}'

I get the following error:

Illegal database name, Reason, name:'testdb, '.

For some reason, an unwanted comma gets added to the new database. Same problem if I specify a preexisting database name. What is causing the issue? How do I resolve the issue?

1条回答
走好不送
2楼-- · 2019-09-10 06:11

Solved. This is the solution:

curl -H "Content-Type: application/json" -X POST http://localhost:5984/_replicate -d "{\"source\": \"http://localhost:5984/source_db\", \"target\": \"http://localhost:5984/target_db\", \"doc_ids\": [\"00021sa5-9915-47f7-bfda-59cf8918f10b\"]}"

These need to be done differently:

  1. Use " instead of ' for Content-Type
  2. use \ in JSON as escape character
查看更多
登录 后发表回答