[GeoNetwork-devel] API & curl / Selections

Dear all, I’m trying the following

export CATALOG=http://localhost:8080/geonetwork
export CATALOGUSER=admin
export CATALOGPASS=admin

rm -f /tmp/cookie;
curl -s -c /tmp/cookie -o /dev/null -X POST “$CATALOG/srv/eng/info?type=me”;
export TOKEN=grep XSRF-TOKEN /tmp/cookie | cut -f 7;
curl -X POST -H “X-XSRF-TOKEN: $TOKEN” --user $CATALOGUSER:$CATALOGPASS -b /tmp/cookie
“$CATALOG/srv/eng/info?type=me”

MUST return @authenticated = true

curl “$CATALOG/srv/fre/q?bucket=s101” -X GET -H “X-XSRF-TOKEN: $TOKEN” --user $CATALOGUSER:$CATALOGPASS -b /tmp/cookie

curl “$CATALOG/srv/api/0.1/selections/s101” -X PUT -H “X-XSRF-TOKEN: $TOKEN” --user $CATALOGUSER:$CATALOGPASS -b /tmp/cookie -H ‘Accept: application/json’ -H ‘Content-Type: application/json’

But the last request always return 0 instead of the number of records retrieved by previous search. Those requests works fine in the API page in a browser. So probably something wrong in the CURL command ?
Any suggestions ?

Thanks

Francois

Hi Francois

I have done a quick test debugging the requests, but the 1st one doesn’t add anything to the bucket (see the code in SelectionManager.updateMDResult), seem just checking if the metadata retrieved in the query is in the bucket, that explains why the 2on one returns 0.

I think should be added another call to select the metadata, no?

Regards,
Jose García

···

On Thu, Nov 30, 2017 at 9:47 AM, Francois Prunayre <fx.prunayre@anonymised.com31…> wrote:

Dear all, I’m trying the following

export CATALOG=http://localhost:8080/geonetwork
export CATALOGUSER=admin
export CATALOGPASS=admin

rm -f /tmp/cookie;
curl -s -c /tmp/cookie -o /dev/null -X POST “$CATALOG/srv/eng/info?type=me”;
export TOKEN=grep XSRF-TOKEN /tmp/cookie | cut -f 7;
curl -X POST -H “X-XSRF-TOKEN: $TOKEN” --user $CATALOGUSER:$CATALOGPASS -b /tmp/cookie
“$CATALOG/srv/eng/info?type=me”

MUST return @authenticated = true

curl “$CATALOG/srv/fre/q?bucket=s101” -X GET -H “X-XSRF-TOKEN: $TOKEN” --user $CATALOGUSER:$CATALOGPASS -b /tmp/cookie

curl “$CATALOG/srv/api/0.1/selections/s101” -X PUT -H “X-XSRF-TOKEN: $TOKEN” --user $CATALOGUSER:$CATALOGPASS -b /tmp/cookie -H ‘Accept: application/json’ -H ‘Content-Type: application/json’

But the last request always return 0 instead of the number of records retrieved by previous search. Those requests works fine in the API page in a browser. So probably something wrong in the CURL command ?
Any suggestions ?

Thanks

Francois


Check out the vibrant tech community on one of the world’s most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot


GeoNetwork-devel mailing list
GeoNetwork-devel@…537…sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geonetwork-devel
GeoNetwork OpenSource is maintained at http://sourceforge.net/projects/geonetwork

Vriendelijke groeten / Kind regards,

Jose García


Veenderweg 13
6721 WD Bennekom
The Netherlands
T: +31 (0)318 416664

Please consider the environment before printing this email.

Hi, fixed by adding both -c and -b eg. "-c /tmp/cookie -b /tmp/cookie " to all curl requests.

Francois

···

2017-11-30 10:05 GMT+01:00 Jose Garcia <jose.garcia@anonymised.com>:

Hi Francois

I have done a quick test debugging the requests, but the 1st one doesn’t add anything to the bucket (see the code in SelectionManager.updateMDResult), seem just checking if the metadata retrieved in the query is in the bucket, that explains why the 2on one returns 0.

I think should be added another call to select the metadata, no?

Regards,
Jose García

On Thu, Nov 30, 2017 at 9:47 AM, Francois Prunayre <fx.prunayre@anonymised.com> wrote:

Dear all, I’m trying the following

export CATALOG=http://localhost:8080/geonetwork
export CATALOGUSER=admin
export CATALOGPASS=admin

rm -f /tmp/cookie;
curl -s -c /tmp/cookie -o /dev/null -X POST “$CATALOG/srv/eng/info?type=me”;
export TOKEN=grep XSRF-TOKEN /tmp/cookie | cut -f 7;
curl -X POST -H “X-XSRF-TOKEN: $TOKEN” --user $CATALOGUSER:$CATALOGPASS -b /tmp/cookie
“$CATALOG/srv/eng/info?type=me”

MUST return @authenticated = true

curl “$CATALOG/srv/fre/q?bucket=s101” -X GET -H “X-XSRF-TOKEN: $TOKEN” --user $CATALOGUSER:$CATALOGPASS -b /tmp/cookie

curl “$CATALOG/srv/api/0.1/selections/s101” -X PUT -H “X-XSRF-TOKEN: $TOKEN” --user $CATALOGUSER:$CATALOGPASS -b /tmp/cookie -H ‘Accept: application/json’ -H ‘Content-Type: application/json’

But the last request always return 0 instead of the number of records retrieved by previous search. Those requests works fine in the API page in a browser. So probably something wrong in the CURL command ?
Any suggestions ?

Thanks

Francois


Check out the vibrant tech community on one of the world’s most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot


GeoNetwork-devel mailing list
GeoNetwork-devel@anonymised.comorge.net
https://lists.sourceforge.net/lists/listinfo/geonetwork-devel
GeoNetwork OpenSource is maintained at http://sourceforge.net/projects/geonetwork

Vriendelijke groeten / Kind regards,

Jose García


Veenderweg 13
6721 WD Bennekom
The Netherlands
T: +31 (0)318 416664

Please consider the environment before printing this email.