Calling REST WS from command line - web-services

I read that REST WS can be called from a command line. I know that they can be invoked from program code, but how directly from command line? I looked around the internet to know how this can be done, but didn't find any information on this. Can anyone please tell me how this can be done? I have developed a rest ws app in grails.

You can use curl from the commandline of any unix-like os.
For example, you can test some sample Facebook API like this:
curl https://graph.facebook.com/19292868552
or to POST:
curl -X POST -d "param1=value1&param2=value2" http://example.com/resource.cgi

You could use curl to ask a URL. I guess your web service can be queried using HTTP?
http://curl.haxx.se/

I believe you want to use cURL to do that.

Related

Giving value to parameter from a file to send it through HTTPPOst

I have been struggling with Jenkins lately, and I'm stuck because I wanna send some parameters through HTTP Post, and I know how to do it, but the thing is that I am saving a Http request response to a file in my workspace, and then I want to use that file, read it and send the text I saved previously to a new HTTP Request, does anyone have any idea how can I achieve this?
Thanks in advance!!!
Install copy artifacts from another project plugin ( copy artifacts) add in build steps store the file in your workspace then you can run a shell script to read the desired content from that file .
if curl would work, that would be a simple way to send a file's contents as your POST body. see this answer.
Jenkins can work with Jmeter and Jmeter is great tool for handling request and response see tutorial

How do I use certificate based authentication with SOAP?

I'm trying to get the wsdl from a soap ws but I'm getting a:
ERR_BAD_SSL_CLIENT_AUTH_CERT
error, when I tried to access https://dummyurl.com:8446/data.php?wsdl from my browser.
I've been given 3 files: ca.crt, pablo.crt and pablo.key but I don't know how to use these files in order to authenticate with this service.
I've also tried to use curl to get the wsdl (without any luck)
curl -k https://dummyurl.com:8446/data.php?wsdl -v -key=pablo.key -cacert=ca.crt -cert=pablo.crt
So my question is, how can I use this certificates and key in order to authenticate and and get the wsdl?
You might find documentation useful
https://curl.haxx.se/docs/sslcerts.html

Using the Vimeo API, how do I replace all videos in a Vimeo album?

Using curl, I'm trying to create a working Vimeo API call that replaces the videos in a Vimeo album with a different set of videos. (The docs are here.) I am successfully deleting the existing videos from the album but my new video info seems to be invisible to Vimeo. Vimeo responds with a 201 ("created") instead of the 200 I'm looking for.
Here is my curl command (with subs for actual data):
curl -H "Authorization: bearer 123abc456def" -X PUT --data "videos=%2Fvideos%2F11111%2C%2Fvideos%2F22222%2C%2Fvideos%2F33333" "https://api.vimeo.com/me/albums/7777777/videos"
I don't know what I'm doing wrong and the Vimeo API docs & playground don't give me the answers I need. My questions and observations:
Should I be url encoding the new video URIs (e.g. 11111,22222, etc)? I have also tried without url encoding and it made no difference. But then the 201 might be telling me it didn't get as far as handling my replacement URIs.
a PUT is required for this operation. I have used PUT successfully to add a video to an existing album (in LiveCode, haven't tried it with curl)
I got the same results when I tried this PUT in LiveCode. I moved the request to curl because more people are familiar with curl.
This is my first rodeo using the Vimeo API. It's a great, vast resource and I've had no problems working with it until this. I'm just stuck on this item and really need it to work!
Thanks for any help you can offer.
This is an ancient, deprecated way of handling batch editing. I'm not sure how it still exists. We will move it to the proper batch creation standard in 3.4.
I think the existing system is supposed to be a comma separated list of video id's, so
curl -H "Authorization: bearer 123abc456def" -X PUT --data "videos=11111%2C22222%2C33333" "https://api.vimeo.com/me/albums/7777777/videos"
is likely the proper request.

Qt : Accessing Secure Objects using session-id from a server

I am working on a Qt application in which I would like to retrieve objects which are tagged #Secured in the Spring-MVC based web-application. I have written the code on the server side for REST authentication and if I use the 'curl' tool, then I am able to access secure services on the server. I would like to know if there is anyway I can replicate the way I am accessing secured services in a QT application. Any help would be nice. Thanks a lot.
curl code :
curl -i -X POST -d j_username=email#email.de -d j_password=password -c /home/username/cookies.txt http://localhost:8080/j_spring_security_check
And for using the session-id to access secure services, I do :
curl -i --header "Accept:application/json" -X GET -b /home/cookies.txt http://localhost:8080/secure_service_method
How can I achieve the same thing in QT. Any help would be nice. Please note, I am not that of an expert in Qt, so please be patient. Thanks a lot.
Converting my comments into this answer:
Judging from your curl command you probably just need to send a POST request and handle the cookies using Qt . Qt provides everything necessary to accomplish this task, have a look at QNetworkAccessManager::post and QNetworkAccessManager::setCookieJar.
The basic steps you need to implement will look like this:
1.) Setup:
QNetworkAccessManager* manager = new QNetworkAccessManager(this);
manager->setCookieJar(new QNetworkCookieJar(manager));
connect(manager,SIGNAL(finished(QNetworkReply*)),this,SLOT(replyFinished(QNetworkReply*)));
2.) Request the cookie
QNetworkRequest request;
request.setUrl(QUrl("http://localhost:8080/j_spring_security_check"));
QByteArray postData;
postData.append("j_username=email#email.de&j_password=password");
manager->post(request,postData);
3.) Use the manager object which then has the cookie to request the protected files.

How do I use the --header option to send cookies with Siege?

I have just started to use Siege to do load/stressing test on a new web server. I am trying to test on my most resource/performance heavy script, but the script requires cookies. What is the proper format for using the --header option in siege?
I have tried this with no luck:
siege --header="Set-Cookie: PHPSESSID=--COOKIE--; iptoken=--COOKIE--" http://www.myurl.com/script.php,
There is no documentation on this that I could find, so any ideas/suggestions would be appreciated.
The answer is to use --header="Cookie: --COOKIE_DATA--" (ref. wiki.wsmoak.net/cgi-bin/wiki.pl?Siege).