Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

unable to update the data in RITM fields using rest api

Rama26
Tera Contributor

hi

below is the script i developed in scripted rest api using "PUT" Method

(function process( /*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {

var obj = {};
obj.number = request.pathParams.number;
obj.short_description = request.pathParams.short_description;
obj.description = request.pathParams.description;
var gr = new GlideRecord("sc_req_item");
gr.addQuery("number", obj.number);
gr.query();
if (gr.next()) {

gr.short_description = obj.short_description;
gr.description = obj.description;
gr.update();
response.setBody(obj);

}
})(request, response);

but the script not working if i send the data like below format. can any one help me on this

{failed: True, msg: template error while templating string: expected token 'end of print statement', got 'tf_templates_path'. String: {{ 2tf_templates_path }}/{{ cloud_platform_name }}/{{ tf_backend_file }}.j2, _ansible_no_log: False}

response: 

{
  "error": {
    "detail": null,
    "message": "Requested URI does not represent any resource"
  },
  "status": "failure"
}
2 REPLIES 2

Namrata Ghorpad
Mega Sage

Hello Rama,

In the Scripted Rest Resource of Rest API add below line in a Relative path

/{number}/{short_description}/{description}

and give the number, short_description, description from the REST API Explorer

find_real_file.png

 

Please mark my answer as helpful/correct if it helps you.

 

Thanks,

Namrata

Hi Namrata,

already created relative path as well. As per the data provided it's populating in the RITM field also.

if i given data in above form in that case only it will not supporting.

find_real_file.png