Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE
sofromt Trusted Contributor.
Trusted Contributor.
862 views

REST API create schedule

Hi

i play a bit with the REST API and tried to create a schedule.

I noticed that for /dp-gui/dp-scheduler-gui/restws/schedule the example shows the following:

{
  "id": "string",
  "disabled": true,
  "jobId": "string",
  "dpName": "string",
  "dpType": "full",
  "dpProtection": "None",
  "dpProtectionParam": "string",
  "dpKeepCatalog": "string",
  "dpKeepCatalogParam": "string",
  "dpLoad": "high",
  "dpPriority": 0,
  "pauseLowerPriorityJobDisabled": true,
  "timeZone": "string",
  "startDate": "2017-10-26T00:00:00",
  "endDate": "2017-11-15T01:23:34",
  "recurrenceType": "ONCE",
  "everyNth": "string",
  "fromTimeOfDay": "string",
  "toTimeOfDay": "string",
  "dayOfMonth": "string",
  "month": "JAN",
  "daysOfWeek": [
    "MON"
  ],
  "nthDayOfWeekInMonth": "FIRST",
  "expectedDurationMillis": 0,
  "cronString": "string",
  "state": "ACTIVE",
  "overlappingIds": [
    "string"
  ],
  "holidaysEnabled": true,
  "debug": {
    "enabled": true,
    "filename": "string",
    "startRange": 0,
    "endRange": 0
  },
  "rest": [
    {
      "rel": "string",
      "href": "string",
      "type": "string",
      "hreflang": "string",
      "title": "string",
      "length": "string"
    }
  ]
}

Do i really have to set all the "string" fields? Like the ID and JobID and all the other obtions?

Can someone post an example of the creation process of a scheudle via REST?

Via omnidbutil a schedule is creates just with:

omnidbutil	-create_schedule	-spectype Backup 	-apptype Filesystem	-specname %Datalistname%	-dpName %Datalistname%	-dpType full	-recurrenceType WEEKLY	-startDate YYYY-MM-DD	-startTime HH:MM	-everyNth 1	-month MAY	-daysOfWeek MON
0 Likes
8 Replies
Micro Focus Expert
Micro Focus Expert

Re: REST API create schedule

Hello @sofromt

I don't have schedules created like that. But I can tell you that ID is needed. This is the way how DP identify the jobs. 

Regards, 

Andres Fallas Salazar
Customer Support Engineer

If you find that this or any other post resolves your issue, please be sure to mark it as an accepted solution.
If you are satisfied with anyone’s response please remember to give them a LIKE by clicking on the bottom at the left of the post and show your appreciation.
0 Likes
sofromt Trusted Contributor.
Trusted Contributor.

Re: REST API create schedule

If i query for existing schedulers the ID is something like a hash based identifier, e.g.:

2165b329-4980-4f57-8a40-39a4a3cba548

Do i really have to think about an ID myself, this looks like a postgres UUID? I think the so called "API documentation" is more than lacking and a pain for everyone who have to move their automation task to REST, please add descriptions for every field..... 

Take inspiraiton from the altassian API documentations, this is what i expect from a API documentation

https://developer.atlassian.com/docs/

Silva Trusted Contributor.
Trusted Contributor.

Re: REST API create schedule

Strongly agree with you about API documentation of DP, it does not have any step/ procedure for newbie REST at all. 

Also when I try to use the Curl link, it always show the login page, I tried to login with DP user/admin but cannot get in. Does anyone have same issue?

0 Likes
Knowledge Partner Knowledge Partner
Knowledge Partner

Re: REST API create schedule

Hi @Silva,

You will need to get an authentication bearer token first. Once you have it all subsequent calls will work. Feed the right WebUser name and password and POST to /auth/realms/DataProtector/protocol/openid-connect/token. This is Data Protector A.10.10,  but works similar on earlier versions.

 2018-09-18_23h13_25.png

Regards,
Sebastian Koehler

---
Please use the Like button below, if you find this post useful.
Tags (5)
0 Likes
sofromt Trusted Contributor.
Trusted Contributor.

Re: REST API create schedule

Hi Silva,

you should first auth via PW like:

curl -X POST "https://[SERVER]:7116/auth/realms/DataProtector/protocol/openid-connect/token" -H  "accept: application/json" -H  "Content-Type: application/x-www-form-urlencoded" -d "username=[USERNAME]&password=[PASSWORD]&client_id=dp-gui&grant_type=password"

You'll get an access_token as response, use this access-token as a bearer auth in your REST-POST/GETS like:

curl -X GET \
https://[SERVERNAME]:7116/dp-gui/dp-scheduler-gui/restws/dp-job \
-H 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICItU3BrT25XVFk5N1hLWG1tYUVObHNXOVVoQkJCZ29HTmhBVG9waWpvTl9vIn0.eyJqdy00NDlhLWJhNDgtZDdjNGE4ODU2ZDk2IiwidHlwIjoiQmVhcmVyIiwiYXpwIjoiZHAtZ3VpIiwiYXV0aF90aW1lIjowLCJzZXNzaW9uX3N0YXRlIjoiYTViMjNlOGMtMWY3My00NmRiLWEwZWUtM2E0MjI1NWExZWI0I.........................................' \

 

Anyway, the Documentation is horrible, please add field informations for the POSTs, just the expected data type is by far not enough, how the hell should i know what the purpose of a field is without trial and error and looking at the response from already configured schedules?

Tags (3)
Knowledge Partner Knowledge Partner
Knowledge Partner

Re: REST API create schedule

Hi @sofromt@Silva,

From what I know Micro Focus is currently working on providing a useful REST API documentation and getting started instructions. Once this has been done it should be available on DocOps. Right now there is nothing.

https://docs.microfocus.com/itom/Data_Protector:2018.09/Develop/Develop

Regards,
Sebastian Koehler

---
Please use the Like button below, if you find this post useful.
0 Likes
Regular Contributor.. Ulrich Windl Regular Contributor..
Regular Contributor..

Re: REST API create schedule

What could be the problem if getting an access token fails with "invalid_grant"? Password wrong, or grant_type wrong?

What are refresh_token and client_id?

0 Likes
Highlighted
Silva Trusted Contributor.
Trusted Contributor.

Re: REST API create schedule

Hi Ulrich,

Fill user with web access user and password as well,

Refresh_token: Leave that field blank

Name of client: "dp-gui"

Grant type: you just type "pasword"

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.