Hi all,
That was helpful but didn't kind of work and I think I might be doing something
wrong here or our ML instance is not configured to use REST API calls.
I saved this code as renameForest.xqy (modified what was needed) and tried to
install it as new extension but I'm failing miserably.. L
curl --anyauth --user user:pass -X PUT -H "Content-type:
application/xquery" -d@"./renameForest.xqy "
http://localhost:8002/LATEST/renameForest
Returned in:
Warning: Couldn't read data from file "/home/ec2-user/renameForest.xqy", this
Warning: makes an empty POST.
so I thought that maybe I'm doing something wrong here due to my limited
knowledge about REST API's & ML and I've spent some time digging through some
code that was is bootstrapping our application and tried using this code:
$ cat resolvefidtoname.xqy
xquery version "1.0-ml";
module namespace ernest =
"http://marklogic.com/rest-api/resource/resolvefidtoname";
import module namespace admin = "http://marklogic.com/xdmp/admin"
at "/MarkLogic/admin.xqy";
declare function ernest:resolvefidtoname($node as element()) as element()?
{
if (fn:data($node) ne 0) then
element {fn:node-name($node)}
{
xdmp:forest-name(fn:data($node))
}
else ()
};
And tried:
curl --anyauth --user user:pass -X PUT -H "Content-type:
application/xquery" -d@"./resolvefidtoname.xqy"
http://localhost:8002/LATEST/resolvefidtoname
but that fails with:
Welcome, user
Page Not Found
I tried http:/.../resolvefidtoname, example straight from documentation but it
didn't work either, so I'm kind of stumped.
$ netstat ... returns ports: 8000, 8001, 8002, 8040, 8041
I used below command to find out on which port I can use REST API calls:
curl -X GET --anyauth --user user:pass -H "Accept:
application/json" http://localhost:8002/LATEST/rest-apis/
and response I got was just this:
{"rest-apis":[]} - not very helpful because when I login in the
browser on port 8001/8000 I can see whatever was bootstrapped, so I think
application is setup to use REST API calls on that port but there's nothing
there.
I went through all ports (even though our application is configured on 8040).
On 8040 I got "Error code: 404, Reason: " - that's it, so not very helpful
either.
What am I doing wrong here?
Is there a way to see where I can save (PUT) this extension?
Do I need to configure another REST API application to add my custom extensions?
Thank you,
Ernest Gulik
From: [email protected]
[mailto:[email protected]] On Behalf Of Dave Cassel
Sent: Friday, October 09, 2015 2:14 PM
To: MarkLogic Developer Discussion <[email protected]>
Subject: Re: [MarkLogic Dev General] Failed to connect to Mark Logic. Invalid
connection information. - cqsh with ML7 on Amazon Linux
An extension that would rename a forest would look something like this (not
tested):
xquery version "1.0-ml";
module namespace ren = "http://marklogic.com/rest-api/resource/rename-forest";
import module namespace admin = "http://marklogic.com/xdmp/admin" at
"/MarkLogic/admin.xqy";
declare function ren:put(
$context as map:map,
$params as map:map,
$input as document-node()*
) as document-node() {
let $old-name := map:get($params, "old-name")
let $new-name := map:get($params, "new-name")
let $config := admin:get-configuration()
let $config := admin:forest-rename($config, admin:forest-get-id($old-name),
$new-name)
return admin:save-configuration($config)
}
You wouldn't use the $input parameter in a case like this. The docs will show
you how to install and call the extension (don't forget the "rs:" prefix on the
parameters).
--
Dave Cassel<http://davidcassel.net>, @dmcassel<https://twitter.com/dmcassel>
Technical Community Manager
MarkLogic Corporation<http://www.marklogic.com/>
http://developer.marklogic.com/
From:
<[email protected]<mailto:[email protected]>>
on behalf of "Gulik, Ernest" <[email protected]<mailto:[email protected]>>
Reply-To: MarkLogic Developer Discussion
<[email protected]<mailto:[email protected]>>
Date: Friday, October 9, 2015 at 11:53 AM
To: MarkLogic Developer Discussion
<[email protected]<mailto:[email protected]>>
Subject: Re: [MarkLogic Dev General] Failed to connect to Mark Logic. Invalid
connection information. - cqsh with ML7 on Amazon Linux
I went through documentation on how to create extensions and looked at that
example<http://docs.marklogic.com/7.0/guide/rest-dev/extensions#id_20771> but
for me these look more like for document manipulation rather than for server
management.
How can I convert xquery for backing up databases to REST API call or maybe
xqyuery code is supported out of the box in REST?
Can we just grab the code for REST API calls from ML8 and simply add them to
our ML7 instance?
It would be great if these are available somewhere (like git)?
Thank you,
Ernest Gulik
From:
[email protected]<mailto:[email protected]>
[mailto:[email protected]] On Behalf Of Danny Sokolsky
Sent: Thursday, October 08, 2015 6:03 PM
To: MarkLogic Developer Discussion
<[email protected]<mailto:[email protected]>>
Subject: Re: [MarkLogic Dev General] Failed to connect to Mark Logic. Invalid
connection information. - cqsh with ML7 on Amazon Linux
You can always create a resourse extension in MarkLogic 7 to fill in the gaps
or to do custom things:
http://docs.marklogic.com/7.0/guide/rest-dev/extensions
-Danny
From:[email protected]<mailto:[email protected]>
[mailto:[email protected]] On Behalf Of Gulik, Ernest
Sent: Thursday, October 08, 2015 3:40 PM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] Failed to connect to Mark Logic. Invalid
connection information. - cqsh with ML7 on Amazon Linux
Upgrade is not an option here, so I guess we can't fully automate
Administrative tasks in ML 7.
Ernest Gulik
From:
[email protected]<mailto:[email protected]>
[mailto:[email protected]] On Behalf Of Danny Sokolsky
Sent: Thursday, October 08, 2015 5:35 PM
To: MarkLogic Developer Discussion
<[email protected]<mailto:[email protected]>>
Subject: Re: [MarkLogic Dev General] Failed to connect to Mark Logic. Invalid
connection information. - cqsh with ML7 on Amazon Linux
There are a lot more REST calls in MarkLogic 8. A good excuse to upgrade :)
From:[email protected]<mailto:[email protected]>
[mailto:[email protected]] On Behalf Of Gulik, Ernest
Sent: Thursday, October 08, 2015 3:33 PM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] Failed to connect to Mark Logic. Invalid
connection information. - cqsh with ML7 on Amazon Linux
This post is for ML8 not ML7.
If there are new calls in guide for ML8 then will they work in ML7 and
documentation is simply not updated?
Should just ignore it and focus on documentation for ML8 guide even though I'm
working on ML 7?
Ernest Gulik
From:
[email protected]<mailto:[email protected]>
[mailto:[email protected]] On Behalf Of Danny Sokolsky
Sent: Thursday, October 08, 2015 5:27 PM
To: MarkLogic Developer Discussion
<[email protected]<mailto:[email protected]>>
Subject: Re: [MarkLogic Dev General] Failed to connect to Mark Logic. Invalid
connection information. - cqsh with ML7 on Amazon Linux
Here is how to backup using REST:
http://docs.marklogic.com/REST/POST/manage/v2/databases/%5Bid-or-name%5D#BackupDB
I'm not sure about renaming a forest.
-Danny
From:[email protected]<mailto:[email protected]>
[mailto:[email protected]] On Behalf Of Gulik, Ernest
Sent: Thursday, October 08, 2015 3:01 PM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] Failed to connect to Mark Logic. Invalid
connection information. - cqsh with ML7 on Amazon Linux
I'm going through documentation and it doesn't seem like it's possible to
simply rename forest.
There are tons of options (clear | merge | restart | attach | detach | retire |
employ | delete) but no simple rename like I have this xquery:
xquery version "1.0-ml";
import module namespace admin = "http://marklogic.com/xdmp/admin"
at "/MarkLogic/admin.xqy";
let $config := admin:forest-rename(admin:get-configuration(),
988693167592881111, "forest-name")
return admin:save-configuration($config)
Is that true that you can't rename forest using REST API?
It doesn't seem like that there's a corresponding REST API call to xquery
function: forest-rename or maybe I'm missing something?
I thought that maybe this will just work and based on "PUT
/manage/v2/forests/{id|name}/properties" I tried:
$ cat forest-name.xml
<forest-properties xmlns="http://marklogic.com/manage">
<name>blaaaaaaaaaa</name>
</forest-properties>
$ curl --anyauth --user user:password -X PUT -d @./forest-name.xml -i -H
"Content-type: application/xml"
http://127.0.0.1:8002/manage/v2/forests/forest-name/properties
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Digest realm="public", qop="auth",
nonce="16f0b33722bdc4ec775e5afca46da21d", opaque="16f244e1594b02d7"
Content-type: application/xml
Server: MarkLogic
Content-Length: 173
Connection: Keep-Alive
Keep-Alive: timeout=5
HTTP/1.1 400 Bad Request
Content-type: application/xml
Server: MarkLogic
Content-Length: 311
Connection: Keep-Alive
Keep-Alive: timeout=5
<error xmlns="http://marklogic.com/manage">
<status-code>400</status-code>
<status>Bad Request</status>
<message-code>MANAGE-INVALIDPAYLOAD</message-code>
<message>MANAGE-INVALIDPAYLOAD: (err:FOER0000) Payload has errors in
structure, content-type or values. Cannot validate payload.</message>
</error>
User/password is correct because this call works fine:
$ curl -s --anyauth --user user:password -X GET -H "Accept: application/xml"
http://localhost:8002/manage/v2/forests/forest-name
I tried all 8** ports and localhost as well. I'm stumped.
It doesn't seem like there are API calls for issuing backups of databases.
(Creating, deleting but not simply backup).
Is it possible to use our xqueries as input to REST API calls, for example?
.... -d @xquery-file.file .... http://..../manage/xquery
Ernest Gulik
From:
[email protected]<mailto:[email protected]>
[mailto:[email protected]] On Behalf Of Gulik, Ernest
Sent: Thursday, October 08, 2015 1:14 PM
To: MarkLogic Developer Discussion
<[email protected]<mailto:[email protected]>>
Subject: Re: [MarkLogic Dev General] Failed to connect to Mark Logic. Invalid
connection information. - cqsh with ML7 on Amazon Linux
Nice,
This seems very promising.
I'll dig into that then.
I have to say that I'm surprised from the speed of responses here, really!
I really appreciate your support. This is awesome!
Thank you!
Ernest Gulik
From:
[email protected]<mailto:[email protected]>
[mailto:[email protected]] On Behalf Of Danny Sokolsky
Sent: Thursday, October 08, 2015 1:01 PM
To: MarkLogic Developer Discussion
<[email protected]<mailto:[email protected]>>
Subject: Re: [MarkLogic Dev General] Failed to connect to Mark Logic. Invalid
connection information. - cqsh with ML7 on Amazon Linux
If what you want to do is script admin tasks, I would recommend using the REST
API:
http://docs.marklogic.com/REST/management
You can then call that from a shell script using curl or something similar,
including all of your favorite scripting languages. The REST api has all of
the best practices built in.
-Danny
From:[email protected]<mailto:[email protected]>
[mailto:[email protected]] On Behalf Of Gulik, Ernest
Sent: Thursday, October 08, 2015 7:23 AM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] Failed to connect to Mark Logic. Invalid
connection information. - cqsh with ML7 on Amazon Linux
Thank you for all your responses.
Installation is straight from ML ec2 template, so nothing complicated.
I was trying to figure it out how to script db backups (and other maintenance
tasks) using command line.
Scripted, because I have a little more control/monitoring in that way.
I have few xqueries that are working fine from qconsole but I want to do as
less manual tasks as possible.
I might just play around curl with POST and authentication and see how that
goes since cqsh is not maintain anymore.
Is there command line tool for MarkLogic that is maintained and working? :)
What built-in tools I could use to automate backups, user creation & assigning
roles, renaming forest?
These exact tasks I'm doing with xqueries (super simple) and just wanted them
automated.
Ernest Gulik
From:
[email protected]<mailto:[email protected]>
[mailto:[email protected]] On Behalf Of Geert Josten
Sent: Thursday, October 08, 2015 1:47 AM
To: MarkLogic Developer Discussion
<[email protected]<mailto:[email protected]>>
Subject: Re: [MarkLogic Dev General] Failed to connect to Mark Logic. Invalid
connection information. - cqsh with ML7 on Amazon Linux
A simple curl --anyauth --user {user}:{pass} http://localhost:8001 might be a
good test as well.
Are you sure you are running the command from the same server on which you
installed MarkLogic? You can typically check that using something like `sudo
service MarkLogic status`. That will also tell you whether MarkLogic service is
up and running.
Kind regards,
Geert
From:
<[email protected]<mailto:[email protected]>>
on behalf of Danny Sokolsky
<[email protected]<mailto:[email protected]>>
Reply-To: MarkLogic Developer Discussion
<[email protected]<mailto:[email protected]>>
Date: Thursday, October 8, 2015 at 12:51 AM
To: MarkLogic Developer Discussion
<[email protected]<mailto:[email protected]>>
Subject: Re: [MarkLogic Dev General] Failed to connect to Mark Logic. Invalid
connection information. - cqsh with ML7 on Amazon Linux
Also, cqsh is a super-old project that has not been touched in a very long time.
What is it you are trying to do? You might try some of the built-in marklogic
tools or a newer project.
-Danny
From:[email protected]<mailto:[email protected]>
[mailto:[email protected]] On Behalf Of David Lee
Sent: Wednesday, October 07, 2015 3:36 PM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] Failed to connect to Mark Logic. Invalid
connection information. - cqsh with ML7 on Amazon Linux
You do not want to use the elb, just checking you were not.
What your issue is could be many things , as many as there are ways to
configure AWS x ML
If you provide some details on how exactly Howe you installed ML, ec2, and what
your ec2 configuration is like,( vpc, network interfaces, using cluster manager
or not , mounted devices ) plus any errors or success logs from
/var/log/messages and ErrorLog.txt , results from the admin GUI that may help.
Sent from my iPad
David A Lee
[email protected]<mailto:[email protected]>
On Oct 7, 2015, at 2:55 PM, Gulik, Ernest
<[email protected]<mailto:[email protected]>> wrote:
Thank you for the quick reply.
Not to ELB,
I'm connecting to private ip address of ec2.
I deployed ML on ec2, downloaded & configured cqsh and followed the guide to
execute the command.
I can't imagine that this would have to be done through ELB since daemon is
listening on 0.0.0.0.
Ernest Gulik
From:[email protected]<mailto:[email protected]>
[mailto:[email protected]] On Behalf Of David Lee
Sent: Wednesday, October 07, 2015 4:45 PM
To: MarkLogic Developer Discussion
<[email protected]<mailto:[email protected]>>
Subject: Re: [MarkLogic Dev General] Failed to connect to Mark Logic. Invalid
connection information. - cqsh with ML7 on Amazon Linux
are you connecting to the elb or the ec2 up?
Sent from my iPhone
On Oct 7, 2015, at 2:16 PM, Gulik, Ernest
<[email protected]<mailto:[email protected]>> wrote:
Hi All,
I'm trying to test cqsh tool with ML7 on Amazon Linux ec2 but for some reason I
get invalid connection Error and did try all combinations that I can came up
with but still nothing.
Normally I can access query console on port 8000 but not through this cli:
$ cqsh -u <username> -p <password> -H <local-ipaddress> -P 8000
Failed to connect to Mark Logic. Invalid connection information.
Error: Connection failed
Goodbye.
I tried localhost, loopback ip and all ports 8001-..9 ports that are used by
the application but no luck.
Can someone point me as to what could be the issue here?
Thank you,
Ernest Gulik
_______________________________________________
General mailing list
[email protected]<mailto:[email protected]>
Manage your subscription at:
http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]<mailto:[email protected]>
Manage your subscription at:
http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
Manage your subscription at:
http://developer.marklogic.com/mailman/listinfo/general