- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2017 03:48 AM
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?
Solved! Go to Solution.
- Labels:
-
Integrations
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2017 05:11 AM
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);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2017 04:09 AM
Hi,
Can't you send the response as a JSON Array?
response.errors = {"root": {"A": "Value"},{"B": "Value"},{"C": "Value"} };
Thanks
Please Hit like, Helpful or Correct depending on the impact of the response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2017 04:36 AM
Hello Alikutty,
Unfortunately, this way I get:
{
"import_set": "ISET0031955",
"staging_table": "imp_create_request",
"result": [
{
"transform_map": "Imp Create Request",
"table": "u_catalog_request_via_api",
"status": "error",
"error_message": " User record not found; Target record not found",
"errors": "[object Object]"
}
]
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2017 05:00 AM
Hi Valery,
Please convert the object to a string, I believe the same should work for your array.
Thanks
Please Hit like, Helpful or Correct depending on the impact of the response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2017 05:03 AM
Hello,
If object is converted to a string it will be represented as string. It will complicate things for integration partner and won't look pretty.
Best regards,
Valery