Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Customize response for Import Set API?

valerybondarchi
Kilo Contributor

Hello all,

I wanted to add an array of errors to the response of import set API by using response object (like response.errors = [])

It works fine for strings, but if I try to add an array, it returns:

{

  "import_set": "ISET0031955",

  "staging_table": "imp_create_request",

  "result": [

      {

          "transform_map": "Imp Create Request",

          "table": "u_catalog_request_via_api",

          "status": "error",

          "error_message": "'u_requested_for'='valery.bondarchik1@wolterskluwer.com': User record not found; Target record not found",

        "errors": "org.mozilla.javascript.NativeArray@12432d1"

      }

  ]

}

Am I out of luck?

1 ACCEPTED SOLUTION

As long as it's a properly formatted JSON String they should be able to parse it.   The ImportSetAPI is returning a string for errors, and I don't believe you can modify it.



On their end they'll just do the equivalent of...



var errorObj = new JSON().decode(response.errors);


View solution in original post

6 REPLIES 6

I believe It would still remain object to them when they access it as JSON {}



Thanks


Please Hit like, Helpful or Correct depending on the impact of the response



json.encode(


As long as it's a properly formatted JSON String they should be able to parse it.   The ImportSetAPI is returning a string for errors, and I don't believe you can modify it.



On their end they'll just do the equivalent of...



var errorObj = new JSON().decode(response.errors);