Hi all.

Thanks Robert for this suggestion.

What got things up and running for us was the "Content-Type: text/plain" header.
That allows you to run all commands and really seems to be needed when POSTing 
to the ISP OC API. Someone should document this somewhere!

TIP: Use the jq command to parse json on the command line, for human sane and 
readable output. https://software.opensuse.org/package/jq

So I am now running (and piping that through jq):
curl -s -X POST -H 'Content-Type: text/plain' -H 'OC-API-Version: 1.0' 
--insecure --user xx:yy https://127.0.0.1:11090/oc/api/cli/issueCommand --data 
@largecommandinatextfile.txt | jq

Or simply:
curl -s -X POST -H 'Content-Type: text/plain' -H 'OC-API-Version: 1.0' 
--insecure --user xx:yy https://127.0.0.1:11090/oc/api/cli/issueCommand --data 
"query option" | jq

This is so much easier to do than executing stuff via dsmadmc.

Have fun!

Regards, Jakob


From: Michael Malitz [mailto:michael.mal...@mm-it.at]
Sent: miðvikudagur, 23. nóvember 2016 08:06
To: Robert Jose <rj...@us.ibm.com>; ADSM: Dist Stor Manager 
<adsm-l@vm.marist.edu>
Cc: michael.malitz <michael.mal...@mm-it.at>; Jakob Jóhannes Sigurðsson 
<jakob.sigurds...@nyherji.is>
Subject: Re: Help running commands via the TSM REST api


Hallo Jose and Jakob.

The Rest API exists for the OC and the CMS.

If you use the OC REST API connection and would like to register a node, please 
try the following example which i

developed for my 3 - day TSM/IBM Spectrum Protect 7.1.7 Update Workshop.

node name: node_black_rest

1.) create a file with the following content  (my test target path/file name is 
C:\scripts\spec713g\sql\batch_register_node.txt)



{

"registerclient" : {

"name":"node_black_rest",

"authentication":"local",

"password":"node_black_rest",

"domain":"standard",

"contact":"class_716_update",

"email":"m...@mm-it.at<mailto:m...@mm-it.at>"

}}

2.)  and then use the following CURL statement  (TSM user id and PW is admin1):



curl -X POST -H "Content-Type: application/json" -H "OC-API-Version: 0" -k 
--user admin1:admin1 https://TSM1:11090/oc/api/servers/SERVER_BLACK/clients 
--data      "@C:\scripts\spec713g\sql\batch_register_node.txt"



hope this helps......

kind rgds  Michael Malitz



Robert Jose <rj...@us.ibm.com<mailto:rj...@us.ibm.com>> hat am 22. November 
2016 um 23:07 geschrieben:


Hello Jakob
I do not know the curl application very well, but I did notice that when
using the -data option, it sets the consume type to
"application/x-www-form-urlencoded". Unfortunately, the OC REST API does
not support this consumption. You will need to change it to consume
"text/plain".

Sorry I couldn't be more help.

Rob Jose
Spectrum Protect OC UI Developer / L3 Support

-----Original Message-----
From: "Jakob Jóhannes Sigurðsson" [mailto:jakob.sigurds...@nyherji.is]
Sent: Friday, November 18, 2016 3:13 AM
To: ADSM-L@VM.MARIST.EDU<mailto:ADSM-L@VM.MARIST.EDU>
Subject: [ADSM-L] Help running commands via the TSM REST api

Hi all.

I saw a message here regarding running registration of clients against the
REST API.
I am not able to get this working and the user did not include his fix in
his reply.

Has anyone successfully tried this? I keep getting Internal Server error
replies and the OC log says:

[11/18/16 11:08:42:206 GMT] 0001eeaf
org.apache.wink.server.internal.registry.ResourceRegistry I The system
cannot find any method in the com.ibm.tsm.gui.rest.CliResource class that
consumes application/x-www-form-urlencoded media type. Verify that a method
exists that consumes the media type specified.

Here is my command:
[jakob@centos-minimal ~]$ curl -s -X POST -H "OC-API-Version: 1.0" -H
"Accept: application/json" --insecure --user jakob:foobar
https://192.168.1.10:11090/oc/api/cli/issueCommand --data "query option"
Response:
{"error":{"httpStatus":"Internal Server
Error","errorCode":500,"message":null}}

Regards, Jakob
jak...@nyherji.is<mailto:jak...@nyherji.is>

Reply via email to