06-18-2021 07:25 AM - edited 06-18-2021 07:26 AM
Hi,
I have been fighting with this for a couple of days, first thinking it was my python code but now I think I need some new glasses or something because I can't see the issue!
Im trying to update an existing template on Prime but get an error when doing so, this has worked before but we have done updates since, tested against versions 3.8 and 3.9. Creating new templates works like a dream no issues at all.
I'm doing a PUT request to /webacs/api/v4/op/cliTemplateConfiguration/template, auth is working as per POST request (postman variables ensure they are the same as well as in my Python code)
I have the most basic body with the minimum requirements as per the docs
{ "cliTemplate": { "name": "DEAN-TEST", "deviceType": "Routers" } }
I get the following error every time
{ "errorDocument": { "httpResponseCode": 500, "httpMethod": "PUT", "message": "java.lang.NullPointerException", "exception": "javax.ws.rs.WebApplicationException: java.lang.NullPointerException", "uriPath": "op/cliTemplateConfiguration/template", "queryParams": "{}", "domain": "ROOT-DOMAIN" } }
Here are the headers
Content-Type:application/json Connection:close Accept:application/json
I've a feeling it is something simple but just can't see it
Thanks for reading and any help
Dean
06-20-2021 05:51 AM
Hello Dean,
First of all, you are getting a 500 HTTP status code in the response which means there is something wrong with the server (Prime) and it cannot handle your request.
The URL for updating an existing template is PUT: https://<PRIME>/webacs/api/v4/data/cliTemplateConfiguration/template.json for working with JSON. Replace op with data. Notice the .json at the very end of the URL.
I noticed the body you sent is:
{ "cliTemplate": { "name": "DEAN-TEST", "deviceType": "Routers" } }
I think you should change the
cliTemplate
to
cliTemplateDTO
This is the key name in the GET response.
Unfortunately, I cannot perform this action because Prime sandbox doesn't give you permission to update an existing template.
06-21-2021 02:32 AM
Hi Osama,
It is definitely /op/cliTemplateConfiguration/template. you don't need the .json if you specify the header Content-Type: application/json as per the documentation.
Also the body contents was correct with cliTemplate, I found out the problem was a missing field, which isn't marked as required in the docs!
it needs the description field or it errors, I will submit this as a bug
My final content is:
{ "cliTemplate": { "name": "DEAN-TEST", "description": "A test template", "deviceType": "Routers", "content" : "Testing", "path" : "My Templates/Provisioning Templates" } }
Thank you for your response.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide