Testing API with Curl - api

I'm writing an API with Flask. Testing with a browser works great:
http://stuff.com/login?username=test#test.com&password=testpassword
returns what I expect.
However, I tried typing this into curl two ways (forgive the ignorance, new to LAMP)
curl http://stuff.com/login?username=test#test.com&password=testpassword
curl -i http://stuff.com/login?username=test#test.com&password=testpassword
Unfortunately, the variables in the query aren't making it to the server, as my error message is similar to passing:
http://stuff.com/login?username=
Help?

I believe the reason is because your shell is evaluating the GET arguments you are using, instead of passing them on as a string. To prevent this, use single quotes around the request url. For example:
curl 'http://stuff.com/login?username=test#test.com&password=testpassword'

Related

Thruk cgi authentication override

I have the latest version of thruk installed with naemon and livestatus. I want to be able to post commands from a python script to cmd.cgi from the same server without the interference of authentication. I have tried the settings of:
use_authentication=0
default_user_name=thrukadmin
but it doesn't seem to work in the thruk gui. When trying to post to the cgi from the thruk gui I get the error, "I'm sorry Dave......"
Any thoughts on why this not working right? The apache server on that system uses ldap to authenticate to the gui, could this be an issue?
Other thoughts?
It's much easier, you don't even need Thruk in the middle. You can simply write to Naemons command_file.
The external command list at https://www.naemon.org/documentation/developer/externalcommands/ contains an example for every possible command.
Here is a shell snippet which schedules a host downtime:
printf "[%lu] SCHEDULE_HOST_DOWNTIME;host1;1478648441;1478638441;1;0;3600;naemonadmin;This is an example comment.\n" `date +%s` > /var/lib/naemon/naemon.cmd
When using Thruk, you can use thruks cli script to send commands:
thruk r -d comment_data=test /hosts/localhost/cmd/schedule_host_downtime
Authentication is only required if you want to send commands by HTTP.

Microsoft Bot Composer Send an HTTP request does not accept variable as Url input

Versions
Bot Composer version: 4.7.0-preview-191208-1
fresh project
yarn command triggered as in docs
Latest Chrome and Edge (chromium) stable version on Windows 10 Pro
Issue
The 'Send an HTTP request' Url field no longer seems to accept a variable as input for me. For example:
${getmyurl()}
The validation seems OK:
Where the getmyurl looks something like (it's not an escaping issue, I tried multiple values here with and without quotes etc...):
# getmyurl()
- just-a-test-string-to-see-if-this-throws-an-invalid-url-exception
The response in the 'Bot Framework Emulator' always gives the message:
BuildQnaAnwserUrl does not have an evaluator, it's not a built-in function or a custom function.
This used to work for me with an older version of the Composer (where the prefix was still an #). Is anyone else having this, is my syntax incorrect somehow?
You can save the Url in a variable at start of conversation. eg. Set a property -> user.Url : urlString. In http method Url field -> Pass it as ${user.Url}. The scope of variable can be defined as per requirement (user/conversation/dialog/turn)
Send an HTTP request

Apache Solr 5.3.1 basic authentication plugin causing issue

I am able to setup the basic authentication plugin using the blog below, for Apache Solr5.3.1, but nothing happens and I am still able to browse through my Solr admin console using firefox without password.
http://lucidworks.com/blog/2015/08/17/securing-solr-basic-auth-permission-rules/
(http)localhost:8501/solr/#/ instead of (http)localhost:8501/solr/admin/
Also when I place the following curl commands I get different results.
curl (http)localhost:8983/solr/admin/authentication
curl (http)localhost:8983/solr/#/authentication
I think I am missing the admin prefix in the console URL but found no way to change it.
Thanks!
After lot of search & debug I finally found out the error.
The curl command was giving an error like message which I overlooked, something like curl: (3) [globbing] nested brace in column 24.
It seems there was some problem in json parsing so I copied and pasted the exact json sample and modified it precisely while keeping the indentation as is and it worked.
curl --user solr:SolrRocks -H 'Content-type:application/json' -d '{
"set-user": {"yepmeasolrupdateuser":"y08klasd"}
}' http://localhost:8983/solr/admin/authentication
Also I found that !! characters in the password field were causing the curl command not to execute properly.
Thanks anyway.

Invoking bamboo plan remotely

I know it is possible to take down a bamboo artifact remotely, I was wondering is it possible to take start a bamboo from a remote box by sending an appropriate HTTP request?
Thanks,.
Here is an example:
curl --user un:pwd -X POST -d "stage&executeAllStages" -d "bamboo.variable.TEST=WORKS" http://10.0.0.0/rest/api/latest/queue/CAP-BR.json
As you can see I am also passing an optional value to Bamboo bamboo.variable.TEST=WORKS
If I understood your question right, then what you want to do is to trigger a build via the rest api of bamboo.
This could offer you some help:
https://answers.atlassian.com/questions/65517/trigger-bamboo-plan-via-rest-call

black screen and error 400 bad request

I was trying telnet into a Web server and send a multiline request message. I have to include in the request message the If-modified-since. I made settings for Win7.
For instance when I type telnet edition.cnn.com 80 on my command prompt, it opens a black empty screen, I don't see any thing that I type.
Then I wrote this line on the black screen GET pageName HTTP/1.0, it returned 400 Bad Request Error and says connection closed. What should I do? I used get pagename for an example.
If you want to use e.g. a telnet client to manually get web-pages, you have to remember the format of a HTTP request header:
GET pageName HTTP/1.0
additional header
additional header
Note that the last line is an empty line. You might also need HTTP/1.1 for certain headers to make sense. Please read a HTTP specification for more information and what headers are standard.
The "black screen" is simply the telnet program running in a command window.
400 is an HTTP error code, meaning you did succesfully send a message to the server, it was just invalid HTTP (probably a simple typo)
The black screen and not seeing what you type is 'normal' behavior for telnet (at least I always had that).
If you use a tool like Putty you can see what you type, so it becomes easier to do this sort of thing, and spot your typo.
See the tutorial here: http://www.hellboundhackers.org/articles/571-spoofing-http-requests-with-putty.html
Hope this helps you.
If you need to anything other than basic interaction with the web server I'd suggesting using a tool specifically made for the job, for example cURL. It will allow you set headers etc.
curl -H "If-Modified-Since:04-Nov-2012 11:59:00 GMT" http://host.com/21838937.asp