HTTP POST to OrientDB generates StringIndexOutOfBoundsException - orientdb

When trying to do the following post:
curl -X POST -u admin:admin -H "Content-Type: application/json"
-d "{\"#class\":\"Job\",\"#rid\":\"\",\"#type\":\"\",\"#version\":\"\",
\"description\":\"Some arbitrary description.\",\"job_status\":\"Open\",
\"job_type\":\"Developer\",\"title\":\"Foo\"}"
http://localhost:2480/document/Phtest/
I get the following response on the client side:
java.lang.StringIndexOutOfBoundsException: String index out of range: 0
And see the following on the OrientDB server side:
java.lang.StringIndexOutOfBoundsException: String index out of range: 0 [ONetworkProtocolHttpDb]
What is the problem?

OrientDB does not accept empty #type and #version. Remove them or fill them with content. Empty #ridis allowed and the POST will return a new RID.

Related

Add existing user to existing group apache ranger

im looking at apache Ranger rest API to add an existing internal user/users to an existing internal group.
I have been looking at the docs and cant seem to find something useful,is there an API for that?
Try following api call:-
curl -ivk -u admin:admin -H "Content-Type: application/json" -d '{"id":13,"createDate":"2020-12-23T07:55:04Z","updateDate":"2020-12-23T07:55:04Z","owner":"rangerusersync","updatedBy":"rangerusersync","name":"atlas","password":"*****","description":"atlas - add from Unix box","groupIdList":[6,59,4,131,133],"groupNameList":["atlas","hadoop","shadow"],"status":0,"isVisible":1,"userSource":1,"userRoleList":["ROLE_USER"],"otherAttributes":"{\"full_name\":\"atlas\",\"original_name\":\"atlas\"}"}' -X PUT https://RANGER_HOST:6182/service/xusers/users
Its little bit big but if user is already added to ranger then run following api to get the id information for users:-
curl -ivk -u admin:admin -H "Accept : application/json" -X GET https://RANGER_HOST:6182/service/xusers/users
Once you have IDs for all users, you can run following curl api to get the json formatted data which you can use to modify and then use PUT method in first API I mentioned:-
curl -ivk -u admin:admin -H "Accept: application/json" -X GET https://RANGER_HOST:6182/service/xusers/users/13
Above Curl api should return something like following:-
{"id":13,"createDate":"2020-12-23T07:55:04Z","updateDate":"2020-12-23T16:45:14Z","owner":"rangerusersync","updatedBy":"admin","name":"atlas","password":"*****","description":"atlas - add from Unix box","groupIdList":[133,6],"groupNameList":["apitest","atlas","hadoop","shadow","ssb"],"status":0,"isVisible":1,"userSource":1,"userRoleList":["ROLE_USER"],"otherAttributes":"{\"full_name\":\"atlas\",\"original_name\":\"atlas\"}"}
you have to modify "groupIdList":[133,6] from the above output copy entire output and pass it with PUT method as shown in the first api call mentioned above.

MarkLogic ingest JSON from external API

I am using Marklogic 9 and try to ingest data from external source into MarkLogic. I made an REST API on port 8031. When I try to execute the following curl command:
curl --anyauth --user admin:admin -i -X POST -d https://services7.arcgis.com/21GdwfcLrnTpiju8/arcgis/rest/services/Geluidsbelasting/FeatureServer/0/query?where=1%3D1&outFields=*&outSR=4326&f=json
-H "Content-type: application/json" -H "Accept: application/json" \
'http://localhost:8031
After executing this statement I receive the error:
Curl: URL is not specified
Can you please help me out!
Many thanks
Erik
Your -d parameter has special characters that are not escaped. Try putting quotes around your -d url. It will prevent your command from getting truncated and misinterpreted at & signs..
HTH!

Curl with restful API

My pc is windows 10. I want to use curl command to get the data from elasticsearch, but I have some problems.
this is my curl command (a small test):
curl "http://localhost:9200/_search" -d '{"query": {"match_all": {}}}'
and the cmd show the error:
{"error":"Content-Type header [application/x-www-form-urlencoded] is not supported","status":406}curl: (3) [globbing] unmatched brace in column 1
curl: (3) [globbing] empty string within braces in column 2
could anyone help me?
thank you in advance.
It seems like you need to provide the proper Content-Type header as well:
curl -H "Content-Type: application/json" -d '{"query": {"match_all": {}}}' "http://localhost:9200/_search"

Neo4j: Using cUrl to execute a query

There are many examples of using cUrl with Neo4j to execute queries but i cannot get it working.
E.g.: https://neo4j.com/blog/export-csv-from-neo4j-curl-cypher-jq/
OS: Windows
DB: Neo4j comunity 3.1.1
cUrl: 7.53.1
"D:\Programme\Tools\curl\curl.exe" -H "Content-Type: application/json" -d '{"statements":[{"statement":
"match (n) return count(n)"}]}' http://localhost:7474/db/data/transaction/commit
Result:
{"results":[],"errors":[{"code":"Neo.ClientError.Request.InvalidFormat","message":"Unable to deserialize request: Unexpe
cted character (''' (code 39)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')\n at [
Source: HttpInputOverHTTP#18463df6; line: 1, column: 2]"}]}
Probably because you are not passing the username and password of the database within the URL. Try this, it worked on mine:
curl -X POST -H 'Content-type: application/json' http://DB_USERNAME:DB_PASSWORD#localhost:7474/db/data/transaction/commit -d '{"statements": [{"statement": "MATCH (n) RETURN n;"}]}'

Curl thowing error while trying to query JIRA with strings in field filter

I need some help with my perl script.
I am new to perl and using curl and despite a lot of searching/ trial and error I am still stumped.
I am trying to use CURL to retrieve a set of jira issues based on the provided JQL.
Unfortunately I am having issues with spaces when I search fields like summary:
my $jql = JiraUrl.'search?jql=summary~"Some%20Silly%20Issue"';
When I curl this...
my $jsonResponse = `curl -D- -u $user:$password -X GET -H "Content-Type: application/json" $jql`;
I get an error ..
{"errorMessages":["Error in the JQL Query: Expecting either \'OR\' or \'AND\' but got \'Silly\'. (line 1, character 77)"],"errors":{}}';
Basicly when I escape the " " with %20 it ignores the "'s
Any help for how to get around this?
It looks like it's a shell escaping issue. The quotes are being interpreted by the shell. Try this:
my $jsonResponse = `curl -D- -u $user:$password -X GET -H "Content-Type: application/json" '$jql'`;