How to update a ticket state via REST - otrs

OTRS 7.0.x provides a REST API. I've found various useful endpoints, but I can't find one where you could update the state of a ticket with a given TicketID. Is there a solution for this problem?

[OTRS 8.0.x isn't out yet, how do you have access to it? resolved by edit]
You can take a look at the TicketUpdate operation. In the file is a description on what you must and what you can provide. With this you can update the ticket state via REST.
Here's an example call for the rest interface to change the state of the ticket.
curl "http://localhost/otrs/nph-genericinterface.pl/Webservice/WebServiceName/RoutingOfTheOperation?UserLogin=admin&Password=1234&TicketID=1" -H "Content-Type: application/json" -d '{"Ticket":{"State":"closed"}}' -X POST

Related

CSRF Token error when attempting to post from CURL to an API endpoint I control. How do I write the request?

I have not utilized this part of Django before, but I have an endpoint which is giving me a 403 error and is telling me that my request needs a csrf token. I was trying to figure out how best to get this since I was attempting to set up a bunch of curl requests to handle some simple queries to the endpoint. Likewise, I was thinking to also use POSTman, but I was not sure where documentation is to handle these request.
I have seen the cookie csrftoken, but when I was attempting to curl with it, it was still giving me a 403. thought it would looking something like this:
curl -d #profilepicturev2.png -b "csrftoken=Ebfn2OlfhSwFjAEQdoQon7wUjbynFoJqrtHMNPla3cy7ZfCMT9cxZ3OQHsbaedam" http://127.0.0.1:8000/api/files/uploader
Maybe I am mistaken? I am trying to send a photo to the server, so i was thinking that this would be correct and wasnt sure if i needed to add additional params in order to append additional data information.
i need to see your code, but i think you need to install "pillow" to send pictures in django !

Add new API-Versions to publisher via REST

I am using APIM 1.10 to add new APIs via the REST-API (see: https://docs.wso2.com/display/AM1100/apidocs/publisher/#!/operations#APIsApi#apisPost)
If I add my first version of an api it works fine. The new API is listed in Publisher.
But if I use the same add-methode with the same data (except the version- and the endpoint-element). I receive the message: "Resource Already Exists"
Question: Which is the best way to add a new version of a existing API via REST?
Should I use update-methode instead, but it is not an update?!?!
Please help me!
Thx, in advance
Marty
Question: Which is the best way to add a new version of a existing API
via REST?
You have to use Copy API and provide new version as query parameter like below.
curl -H "Authorization: Bearer b0982cd2aacd463ff5f63cd5ebe58f4a" -X POST "http://127.0.0.1:9763/api/am/publisher/v0.9/apis/copy-api?apiId=890a4f4d-09eb-4877-a323-57f6ce2ed79b&newVersion=2.0.0"
My final solution looks like this:
read all existing apis
cluster the apis via name, context, versions in a hashmap
before adding a new api i check if a other version of this api exists
if yes, i use the copy rest-methode with addition update-methode
if no, i can use the add-methode
Regards
Marty

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).