Pass Arraylist in post request to neo4j - rest

I want to pass an array list to post request to Neo4j server, instead I get an warning at startup when I try run systemctl status neo4j.
WARN Failed to load plugin [ServerPlugin[KShortestPaths]]:
Unsupported parameter type: java.util.ArrayList
I want to pass something like:
{
"concept1":"C0000039",
"vocabulary": ["MSH", "NDFRT"]
}

Related

Substream Source(EntitySource) cannot be materialized more than once

I'am trying to implement file upload functionality in my application using Akka HTTP. I am using Akka version 2.5.32 and Scala version 2.11.12. I write a simple code with directive storeUploadedFile, like in documentation (https://doc.akka.io/docs/akka-http/current/routing-dsl/directives/file-upload-directives/storeUploadedFile.html):
def uploadFile: Route = (post & path("uploadFile")) {
storeUploadedFile("uploadFile", getDestination) {
(info, file) => complete(JsObject("path" -> JsString(file.getAbsolutePath)))
}
}
private def getDestination(info: FileInfo): File = File.createTempFile(tmpDir, info.fileName)
But when i try to send a request to my application:
curl -F "uploadFile=#data.csv" -X POST localhost:8080/uploadFile
I'll get internal server error and exception:
ERROR [ActorSystemImpl] - Error during processing of request: 'Substream Source(EntitySource) cannot be materialized more than once'. Completing with 500 Internal Server Error response. To change default exception handling behavior, provide a custom ExceptionHandler.
java.lang.IllegalStateException: Substream Source(EntitySource) cannot be materialized more than once
What should i do to upload file without this exception?

Writing log to gcloud Vertex AI Endpoint using gcloud client fails with google.api_core.exceptions.MethodNotImplemented: 501

Trying to use google logging client library for writing logs into gcloud, specifically, i'm interested in writing logs that will be attached to a managed resource, in this case, a Vertex AI endpoint:
Code sample:
import logging
from google.api_core.client_options import ClientOptions
import google.cloud.logging_v2 as logging_v2
from google.oauth2 import service_account
def init_module_logger(module_name: str) -> logging.Logger:
module_logger = logging.getLogger(module_name)
module_logger.setLevel(settings.LOG_LEVEL)
credentials= service_account.Credentials.from_service_account_info(json.loads(SA_KEY_JSON))
client = logging_v2.client.Client(
credentials=credentials,
client_options=ClientOptions(api_endpoint="us-east1-aiplatform.googleapis.com"),
)
handler = client.get_default_handler(
resource=Resource(
type="aiplatform.googleapis.com/Endpoint",
labels={"endpoint_id": "ENDPOINT_NUMBER_ID",
"location": "us-east1"},
)
)
#Assume we have the formatter
handler.setFormatter(ENRICHED_FORMATTER)
module_logger.addHandler(handler)
return module_logger
logger = init_module_logger(__name__)
logger.info("This Fails with 501")
And i am getting:
google.api_core.exceptions.MethodNotImplemented: 501 The GRPC target
is not implemented on the server, host:
us-east1-aiplatform.googleapis.com, method:
/google.logging.v2.LoggingServiceV2/WriteLogEntries. Sent all pending
logs.
I thought we need to enable api and was told it's enabled, and that we have: https://www.googleapis.com/auth/logging.write
what could be causing the error?
As mentioned by #DazWilkin in the comment, the error is because the API endpoint us-east1-aiplatform.googleapis.com does not have a method called WriteLogEntries.
The above endpoint is used to send requests to Vertex AI services and not to Cloud Logging. The API endpoint to be used is the logging.googleapis.com as shown in the entries.write method. Refer to this documentation for more info.
The ClientOptions() function should have logging.googleapis.com as the api_endpoint parameter. If the client_options parameter is not specified, logging.googleapis.com is used by default.
After changing the api_endpoint parameter, I was able to successfully write the log entries. The ClientOptions() is as follows:
client = logging_v2.client.Client(
credentials=credentials,
client_options=ClientOptions(api_endpoint="logging.googleapis.com"),
)

Fetching data from json file in protractor

I am working on protractor testing framework to test the Angular Js application.
I am stuck in a scenario where I want to fetch the data
(eg: Test URL,Username,Password)from external file say Json File.
I have created one json file for this and written code to read the data from this json file but I am getting the error
as:
DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
[11:03:10] I/launcher - Running 1 instances of WebDriver
[11:03:10] I/local - Starting selenium standalone server...
[11:03:12] I/local - Selenium standalone server started at http://10.212.134.201:59697/wd/hub
[11:03:15] E/launcher - Error: Error: Cannot find module 'E:LAM WAH EE_Testing EnviornmentDetailed_Sheet - Copy.geojson'
where Detailed_Sheet - Copy.geojson is the file where I have given the url name and username and password.
Please anyone having idea about this help me so that I will get to know where is my mistake.
Please see below example, the example assume we have two files and they are in same folder:
1) login.auth.json, its content as below:
{
"loginurl": "http://172.16.99.47:3001",
"username": "azizi#hlwe.com",
"password": "abcd#1234"
}
Note: For json file, you no need to use module.exports or exports.xxx to export the json data, you only need to write a valid json data in json file and use require() to import, then you will get the json data.
2) test.js, its content as below:
var auth = require('./login.auth.json');
describe('Opne the clinicare website by logging into the site', function() {
it('Should Add a text in username and password fields and hit login button', function() {
browser.driver.manage().window().maximize();
browser.get(auth.loginurl);
//Perform Login:UserName
element(by.model('accessCode')).sendKeys(auth.username);
//Perform Login:Password
element(by.model('password')).sendKeys(auth.password);
//Perform Login:LoginButton
element(by.css('.btn.btn-primary.pull-right')).click();
});
});

kie server response handling

I'm getting below error when I tried to hit kie server from java application
Exception in thread "main"
org.kie.server.client.KieServicesException: Error while creating
service response! The actual result type class
org.kie.server.api.model.KieContainerResourceList does not match
the expected type class
org.kie.server.api.model.KieServerInfo!
Can anyone please help me in resolving this
Getting error at below location in my code :
KieServicesClient client = KieServicesFactory.newKieServicesClient(config);
I suppose that you are using REST transport protocol in Kie server client.
It seems that you put wrong server URL parameter to your instance of KieServicesConfiguration. Correct URL looks like this:
http://<server>:<port>/<context>/services/rest/server
Your server URL seems to be:
http://<server>:<port>/<context>/services/rest/server/containers
Which is actually URL of endpoint for retrieving containers list in Kie server.

Modifying the Request parameters throws Internal Server Error

When using the Python Eve Database hooks I am trying to modify the request parameters on a post call I am getting the below error
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>500 Internal Server Error</title>
<h1>
Internal Server Error
</h1>
<p>The server encountered an internal error and was unable to complete your
request.Either the server is overloaded or there is an error in the
application.
</p>
And when I remove the code fragment to modify the Request Parameters the resource is created successfully.
Please find the code snippet as :-
__author__ = 'sappal'
from eve import Eve
import time
def insert_people(items):
# retrieve request parameter, if present
print items['userid']
print items['email']
items['userid']= "Tushar_Sappal" + str(int(time.time()))
items['email'] = "sappal.tushar"+str(int(time.time()))+"#gmail.com"
print items
# Creating the instance of the EVE Application
app = Eve()
app.on_insert_people += insert_people
if __name__== '__main__':
app.run(host='0.0.0.0')
items is a list so you should update your code like this:
def insert_people(items):
for item in items:
item['userid']= "Tushar_Sappal" + str(int(time.time()))
item['email'] = "sappal.tushar"+str(int(time.time()))+"#gmail.com"
While in development, you usually want to run your application in debug mode, so you can get a full stack-trace with the error:
app.run(debug=True)
Just make sure to disable the debug mode when running in production.