cancel
Showing results for 
Search instead for 
Did you mean: 

NetBackup Api policy config patch not working

Asheeholic
Level 3

I used netbackup API in swagger for test, and GET, PUT, DELETE is working, but the PATCH is not working.

The Policy Name is "OEL7-1_ORACLE"

The cURL is

 

curl -X 'PATCH' \
  'xx:1556/netbackup/config/policies/OEL7-1_ORACLE' \
  -H 'accept: */*' \
  -H 'X-NetBackup-Audit-Reason: xx' \
  -H 'Content-Type: application/vnd.netbackup+json;version=7.0' \
  -d '{
  "data": {
    "type": "policy",
    "id": "OEL7-1_ORACLE",
    "attributes": {
      "policy": {
        "policyName": "OEL7-1_ORACLE",
        "policyAttribute": {
          "active": true
        }
      }
    }
  }
}'

 

I want to that policy make active 'true', but the Error is 400 and

{  "errorCode": 9926,  "errorMessage": "Input JSON is invalid",  "attributeErrors": {},  "fileUploadErrors": [],  "errorDetails": []}

 

What did i miss?

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Asheeholic 

I figured it out - you use the Chrome inspect (network tab) option to look at the payload sent. What the WebUI sends is different to the documentation (doesn't help).

All you need to do is change the data payload to something like this (your header lines should be fine as is).

{
    "data": {
        "type""patchPolicyRequest",
        "id""OEL7-1_ORACLE",
        "attributes": {
           "policy": {
                "policyAttributes": {
                    "active": false
                }
            }
        }
    }
}


So the "type" is documented incorrectly - it should be patchPolicyRequest (not policyPatchRequest), and within the attributes section you need an additional "policy" section before the policyAttributes.

Cheers
David

View solution in original post

8 REPLIES 8

davidmoline
Level 6
Employee

Hi @Asheeholic 

You should mention the NetBackup version as the API calls vary somewhat between versions. I'm guessing that you are using version 10.0 though due to the content type version.

Anyway, Review the documentation - your input doesn't look correct. You've added the policy name again in the data section which is not correct (the policy is definde in the base URL). The type of operation in the data section is not correct - it should be policyPatchRequest, not policy. The policyAttribute should be policyAttributes.

Try something like the below and see if you can make it work. I've have also had trouble with getting the syntax correct at times and the documentation is not good in helping in finding syntax errors (IMHO).

 

 

 

curl -X 'PATCH' \
  'xx:1556/netbackup/config/policies/OEL7-1_ORACLE' \
  -H 'accept: */*' \
  -H 'X-NetBackup-Audit-Reason: xx' \
  -H 'Content-Type: application/vnd.netbackup+json;version=7.0' \
  -d '{
  "data": {
    "type": "policyPatchRequest",
    "id": "OEL7-1_ORACLE",
    "attributes": {
      "policyAttributes": {
        "active": true
      }
    }
  }
}'

 

 

Cheers
David

quebek
Moderator
Moderator
   VIP    Certified

hey

Maybe I am old but I don't get why would you like to use APIs to activate policy fi there is nice and easy way of doing the same via command line:

bpplinfo policy name -modify -active

just thinking out loud....

Yes, This NetBackup version is 10, and I fixed that cURL, but still not working.

I agreed with that the documentation is not good for finding error.

Anyway, the Syntex is

curl -X 'PATCH' \  'xx/netbackup/config/policies/OEL7-1_ORACLE' \  -H 'accept: */*' \  -H 'Content-Type: application/vnd.netbackup+json;version=7.0' \  -d '{  "data": {    "type": "policyPatchRequest",    "id": "OEL7-1_ORACLE",    "attributes": {      "policyAttributes": {        "active": false      }    }  }}'

and the result is still saying that

{  "errorCode": 9926,  "errorMessage": "Input JSON is invalid",  "attributeErrors": {},  "fileUploadErrors": [],  "errorDetails": []}

 I think the documentation of API is something wrong... I'm trying to find the other way. please tell me if you find out the way.

Thank you.

ps. I found out that this policy patch config api came out in 9.1 version.

Hi @quebek 

Yes I think you must be an old timer like me.....

While what you say is true, what if you don't have a command line to access or access as superuser. Not everyone has the luxury of being given elevated access to the backup hosts.

David

Hi @Asheeholic 

If you can figure out how to get more verbose logging for the WebUI backen server, then you can replicate the API call by activating/deacivating a policy in the GUI. I can see it uses the same API call in the webserver logs, but no details that I can find about the payload sent. 

I'm asking internally if there is a way to increase the webserver logging without breaking things. If you know then please share. 

Cheers
David

Hi @Asheeholic 

I figured it out - you use the Chrome inspect (network tab) option to look at the payload sent. What the WebUI sends is different to the documentation (doesn't help).

All you need to do is change the data payload to something like this (your header lines should be fine as is).

{
    "data": {
        "type""patchPolicyRequest",
        "id""OEL7-1_ORACLE",
        "attributes": {
           "policy": {
                "policyAttributes": {
                    "active": false
                }
            }
        }
    }
}


So the "type" is documented incorrectly - it should be patchPolicyRequest (not policyPatchRequest), and within the attributes section you need an additional "policy" section before the policyAttributes.

Cheers
David

I was almost in despair. I was annoyed about the clients swearing at me. But it seems you saved me. Thank you.

Hi @Asheeholic 

I'm glad I could help - I now need to figure out who I need to tell to get the documentation updated.

Cheers
David