How do I run gremlin queries through OrientDB http api - orientdb-2.1

in the browser studio I CAN run the following command:
select gremlin("g.v('12:0')") from #12:0
and i get a result.
with the http api I CAN run the following command:
<server>:[<port>]/command/pokeloungestage/sql/select * from #12:0
and i get a result.
with the http api I can CAN NOT run the following command:
<server>:[<port>]/command/pokeloungestage/sql/select gremlin("g.v('12:0')") from #12:0
with postman I CAN run the following command:
---with proper auth & cookie headers
<server>:[<port>]/command/pokeloungestage/gremlin/g.v("12:0")
with the http api I CAN NOT run the following command:
<server>:[<port>]/command/pokeloungestage/gremlin/g.v("12:0")

The problem was that I was running GET requests, gremlin http API must use POST method.

Related

Browser client can't connect to DynamoDB in Docker container

I've been using #aws-sdk/client-dynamodb server-side (SvelteKit / NodeJS) connecting to localhost Docker container with instance of amazon/dynamodb-local:latest which works well. I used AWS CLI to configure tables, etc. I've created the client using the simplest configuration:
const client = new DynamoDBClient({ endpoint: 'http://localhost:8000' });
This works server-side, but when the same is executed client-side along with a command, I get a message that the region is missing. I've tried passing region: 'none', but then I get a message that the credentials are missing. Adding dummy credentials enables the command to execute, but I don't get an expected response. For example, sending the ListTablesCommand returns an empty array. If I do the same from the AWS CLI, I get the correct response.
Does the DynamoDB client run client-side, i.e., in the browser? Or am I missing something else?
No it doesn't run in a browser, You will need API Gateway and some backend code to connect a browser to Dynamodb.

Return custom error from appengine behind Google Cloud Endpoints

I am using flask and python 3.6 as a backend service that is deployed to App Engine in GCP. This backend is sitting behind Google Cloud Endpoints deployed in Cloud Run. Endpoints takes all my 404 messages and just returns 404 Not Found. I want to send a more informative error message with the 404 code. Is there any way to do so using my current setup? Thanks
You can create a custom 404 html page:
#app.errorhandler(404)
def page_not_found(e):
return render_template('404.html'), 404
Then, you need to create 404.html file.
You can use the Python Endpoints library to send HTTP error codes with a custom message as follows:
message = 'No entity with the id "%s" exists.' % entity_id
raise endpoints.NotFoundException(message)
You can find more info in the docs

Find out if you are running in a command and the command parameters in Symfony

We have a service that can be called from a Symfony command and from a normal web request. Is there a way to find out if the service was called from a command or from a web request? If so, if it was called from a command, is there a way to find out the parameters that were used when running the command?
In symfony Console,
the command line context does not know about your VirtualHost or domain name
It means that you can check the request scheme, host, base_url and base path since these request properties have no values in the console context unless you configure them (https://symfony.com/doc/current/console/request_context.html#configuring-the-request-context-globally)
Hi you can use this to know if the service is used from the cli, if it runs with apache you will get this apache2handler
if(php_sapi_name() === 'cli') {
//some code
}
https://www.php.net/manual/en/function.php-sapi-name.php

send grid & parse 502 Bad Gateway with nginx

I am trying to migrate my parse application over to digital ocean and followed this guide :
https://www.digitalocean.com/community/tutorials/how-to-migrate-a-parse-app-to-parse-server-on-ubuntu-14-04
Everything works perfectly fine until I get to the very end Test Parse Server ( Executing Example Cloud Code ) section
I tested the cloud code for the sample cloud code that was provided in the tutorial :
Parse.Cloud.define('hello', function(req, res) {
res.success('Hi');
});
so I got a Hi back in my browser as well as in postman.
See image here : https://cloudup.com/cH2dbBx1KTo

Then I test the function that uses sendgrid's service to send emails (http://blog.parse.com/announcements/introducing-the-sendgrid-cloud-module/), my cloud code file looks like this :
see image : https://cloudup.com/cD6MNRP3Tft
and now I try to run my post request from postman and I get an error even on my hello function that was working before
See image : https://cloudup.com/cIkwJ6552_5
So I look around and figure out that its an issue with my sendgrid import
var sendgrid = require("sendgrid");
sendgrid.initialize(“xxxxxx”, “xxxxx.”);
in these lines.
does anyone have any experience with digital ocean cloud code and send grid emailing service please help me out I will be grateful as this is the last step left and I will be done with my migration :)
cheers
Tanzeel
you have to specify server URL in parse config file. It is required and could be the reason why you cant run cloud code.
"PARSE_SERVER_URL": "http://localhost:1337/parse"
The url has be the same what you are using. There is also error in Nginx config in that tutorial, I explained it here https://serverfault.com/questions/765627/cannot-post-get-over-ssl/766428#766428
So I looked up at pm2 and to see real-time logs the command is
pm2 logs
at first when I ran the command I saw some errors, maybe they were there from before :
Then I tried the hello cloud function from postman app to test for its output in pm2 logs and I got the following :
Next I try to run my sendMail sendgrid function and I find out the the api-key I had used in my sendgrid function was throwing an error
ReferenceError: XXXXXXXXXXXX is not defined
So I went back to my cloud code and used quotes around my api-key parameter and passed it as a string in my send grid initialize function. Then I retry and get
[Error: The provided authorization grant is invalid, expired, or revoked]
So I went back to my sendgrid account and made sure that the api-key I was using was the correct one and it seemed to be just fine. I tested again and got the same error again so I decided to generate a new api-key just in case.
So I realize that I was not using the api-key but instead API KEY ID :
When we create a new api-key on sendgrid they give us the actual api key once and they ask us to store it in some secure place :
We can only display the key above one time. Please store it somewhere safe because as soon as you navigate away from this page, we will not be able to retrieve or restore this generated token.
So after I used an actual api-key I was able to send emails 😃
But one small issue still remains and I am not sure if its because of postman that I am using to run cloud code or something in the parse server or nginx that is still returning me with a 502 Bad Gateway as a response
But when I look at the logs for my parse server I do see a
parse-wrapper-0 { message: 'success' }
but it never gets back to me in my postman and instead I am getting a 502 error not sure why but the emails are being sent succesfully :)

cURL and ActiveMQ

I need an example on how to read/write to an ActiveMQ queue over HTTP in C or C++ using cURL (or something else, I'm open to anything at this point).
I have working code in C#, but it doesn't help.
Any help is appreciated,
Thank you.
First I assume:
You are running activemq 5.5.0
You are using the default activemq configuration that enables the web-console
Test it by pointing a browser to http://localhost:8161/admin
By cURL you mean libcurl and a command line example is sufficient
Example:
Create a queue named test, set the body to hello world.
Note: [clientId] this a unique string to identify your subscribe otherwise a new consumer will be created for each request see REST
$ curl -d 'body="Hello World"' "http://localhost:8161/demo/message/test?type=queue&clientId=consumerA"
Pop the message of the queue
$ curl -X delete "http://localhost:8161/demo/message/test?type=queue&clientId=consumerA"
You should see "Hello World"
Finally unsubscribe from the queue
$ curl -d 'action=unsubscribe' "http://localhost:8161/demo/message/test?type=queue&clientId=consumerA"
You should be able to monitor all of the above operations from the admin interface
Until version 5.8, REST API was part of the Web Samples and was mapped
to http://localhost:8161/demo/message url. From 5.8 onwards, the API
is available by default at http://localhost:8161/api/message url
http://activemq.apache.org/rest.html

Resources