Neo4j: Using cUrl to execute a query - rest

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;"}]}'

Related

ADO Linking requirement & test case work items with Rest API issue

I'm trying to link a ADO Requirement work item to a ADO Test Case work item. I'm making this call:
curl -u :********** -X PATCH -H "Content-Type: application/json-patch+json" -H "Accept: application/json-patch+json" -d "[{{\"op\": \"test\", \"path\": \"/rev\",\"value\": 3 },{\"op\": \"add\", \"path\": \"/relations/-\", \"value\":\"{\"rel\": \"System.LinkTypes.Dependency-forward\",\"url\": \"https://***.***.com/{Organisation}/_apis/wit/workItems/{ID}\",\"attributes\": {\"comment\": \"Making a new link for the dependency\"}}}}]" https://***.***.com/{Organisation}/{Project}/_apis/wit/workItems/{ID}?api-version=6.0
as per: https://learn.microsoft.com/en-us/rest/api/azure/devops/wit/work-items/update?view=azure-devops-rest-7.1#add-a-link
But I'm having this error:
{"$id":"1","innerException":null,"message":"You must pass a valid patch document in the body of the request.","typeName":"Microsoft.VisualStudio.Services.Common.VssPropertyValidationException, Microsoft.VisualStudio.Services.Common","typeKey":"VssPropertyValidationException","errorCode":0,"eventId":3000}
I found my answer, the JSON was badly parse. I used a online JSON linter to fix it. https://jsonlint.com/
curl -u :********** -X PATCH -H "Content-Type: application/json-patch+json" -H "Accept: application/json-patch+json" -d "[{\"op\": \"add\", \"path\": \"/relations/-\", \"value\":{\"rel\": \"Microsoft.VSTS.Common.TestedBy-Forward\",\"url\": \"https://***.***.com/{Organisation}/_apis/wit/workItems/{ID}\",\"attributes\": {\"comment\": \"Making a new link for the dependency\"}}}]" https://***.***.com/{Organisation}/{Project}/_apis/wit/workItems/{ID}?api-version=6.0

problem to make a query REST put, a elasticsearch

I want to send data in the format json a elasticsearch but I can not do it
I'm using elasticsearch version 7.0.1 and curl 7.64, I'm on windows 10
curl -X PUT "localhost:9200/customer/_doc/1?pretty" -H 'Content-Type: application/json' -d'
{
"name": "John Doe"
}
'
i have this error messages :
{
"error" : "Content-Type header [application/x-www-form-urlencoded] is not supported", "status" : 406
}
curl: (6) Could not resolve host: application
curl: (3) URL using bad/illegal format or missing URL
On Windows, you need to use double quotes everywhere, not single quotes:
curl -X PUT "localhost:9200/customer/_doc/1?pretty" -H "Content-Type: application/json" -d "{ \"name\": \"John Doe\" }"

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!

Create topic in Message-Hub via curl command

I am trying to create a topic in Message-Hub using a curl command.
I followed this yaml: https://github.com/ibm-messaging/message-hub-docs/blob/master/kafka-administration-api/KafkaTopicManagement.yaml
I'm getting HTTP 405 Method Not Allowed when running the following:
curl -X POST --tlsv1.2 -vk -H "Content-Type: application/vnd.kafka.binary.v1+json" -H "X-Auth-Token: apikey from the environment variable of my app" https://kafka-rest-prod01.messagehub.services.us-south.bluemix.net/topics -d "{ \"TopicCreateParam\" { \"name\": \"my.test\" }}"
Thanks for any help.
#jd76 three problems here:
your URL is missing the /admin/ path
your content-type should just be plain json
TopicCreateParam is just the name of the type in the swagger yml.
Try:
curl -H "Content-Type: application/json" -H "X-Auth-Token: apikey from the environment variable of my app" -d "{ \"name\": \"my.test\" }" https://kafka-rest-prod01.messagehub.services.us-south.bluemix.net/admin/topics

How to pass null as values to any variable in cURL command or Browser command for REST ATG?

First call:
curl -L -v \
-c customer_cookies.txt \
-b customer_cookies.txt \
-H "Content-Type: application/json" \
-d "{\"couponClaimCode\":\"0001\"}" \
"http://localhost:7103/rest/model/atg/commerce/promotion/CouponActor/claimCoupon"
Second call:
http://localhost:7103/rest/model/atg/commerce/promotion/CouponActor/claimCoupon?couponClaimCode=0001
Both calls are doing the same thing: passing coupon code. Suppose if i want to pass null as a value, then how should i do that?
JSON supports null. This
{"couponClaimCode": null}
is valid JSON. If the code that accepts the POST handles JSON correctly, this should work.
Passing a null value of couponClaimCode as a query param depends on what your backend understands. Would
?couponClaimCode=
be interpreted as the empty string "" or as null? What about
?couponClaimCode=null
Is this the string "null" or null? You will have to look into your backend code to find out.
This worked for me
curl -L -v
-c customer_cookies.txt
-b customer_cookies.txt
-H "Content-Type: application/json"
-d "{\"couponClaimCode\":\"\"}"
"http://localhost:7103/rest/model/atg/commerce/promotion/CouponActor/claimCoupon"