Hello Community
I have an API that works fine in cloud, but in the migration returns that error in javascript.
Could you help to fix that issue.
Thanks in advance
Solved! Go to Solution.
Sure, upload the complete js.
The error line is the 59 "responseValidate.mso_glosa_cor_ofer = mso_glosa_cor_ofer.trim();//revisar tipo de campo que genera falla"
function validateNulos(numtelefono, nombreCliente, primerApellido, segundoApellido, numAbonado, numIdentidad, tipoAbonado, valorCliente, codCategoria, desCategoria, wlc03wo_o_cod_sub_seg, awlc03wo_o_desc_sub_seg, FOLIO, MONTO, SALDO, FECHA_VENCIMIENTO, NRO_VENCIDO, MONTO_VENCIDO, acarpz3o_flg_arp, acarpz3o_glosa, mso_prioridad, mso_glosa_ofer, mso_glosa_cor_ofer, mso_oferta_moneda, mso_precio) { var responseValidate = {}; if (numtelefono == null || numtelefono == "{}") numtelefono = ""; if (nombreCliente == null || nombreCliente == "{}") nombreCliente = ""; if (primerApellido == null || primerApellido == "{}") primerApellido = ""; if (segundoApellido == null || segundoApellido == "{}") segundoApellido = ""; if (numAbonado == null || numAbonado == "{}") numAbonado = ""; if (numIdentidad == null || numIdentidad == "{}") numIdentidad = ""; if (tipoAbonado == null || tipoAbonado == "{}") tipoAbonado = ""; if (valorCliente == null || valorCliente == "{}") valorCliente = ""; if (codCategoria == null || codCategoria == "{}") codCategoria = ""; if (desCategoria == null || desCategoria == "{}") desCategoria = ""; if (wlc03wo_o_cod_sub_seg == null || wlc03wo_o_cod_sub_seg == "{}") wlc03wo_o_cod_sub_seg = ""; if (awlc03wo_o_desc_sub_seg == null || awlc03wo_o_desc_sub_seg == "{}") awlc03wo_o_desc_sub_seg = ""; if (FOLIO == null || FOLIO == "{}") FOLIO = ""; if (MONTO == null || MONTO == "{}") MONTO = ""; if (SALDO == null || SALDO == "{}") SALDO = ""; if (FECHA_VENCIMIENTO == null || FECHA_VENCIMIENTO == "{}") FECHA_VENCIMIENTO = ""; if (NRO_VENCIDO == null || NRO_VENCIDO == "{}") NRO_VENCIDO = ""; if (MONTO_VENCIDO == null || MONTO_VENCIDO == "{}") MONTO_VENCIDO = ""; if (acarpz3o_flg_arp == null || acarpz3o_flg_arp == "{}") acarpz3o_flg_arp = ""; if (acarpz3o_glosa == null || acarpz3o_glosa == "{}") acarpz3o_glosa = ""; if (mso_prioridad == null || mso_prioridad == "{}") mso_prioridad = ""; if (mso_glosa_ofer == null || mso_glosa_ofer == "{}") mso_glosa_ofer = ""; if (mso_glosa_cor_ofer == null || mso_glosa_cor_ofer == "{}") mso_glosa_cor_ofer = ""; if (mso_oferta_moneda == null || mso_oferta_moneda == "{}") mso_oferta_moneda = ""; if (mso_precio == null || mso_precio == "{}") mso_precio = ""; var monto_pre = Number(MONTO).toString(); //elimina decimal var saldo_pre = Number(SALDO).toString(); //elimina decimal //var folio_pre = Number(FOLIO).toString(); var nuevaFecha = FECHA_VENCIMIENTO.substring(6,8)+FECHA_VENCIMIENTO.substring(4,6)+FECHA_VENCIMIENTO.substring(0,4); responseValidate.numtelefono = numtelefono; responseValidate.nombreCliente = nombreCliente; responseValidate.primerApellido = primerApellido; responseValidate.segundoApellido = segundoApellido; responseValidate.numAbonado = numAbonado; responseValidate.numIdentidad = numIdentidad; responseValidate.tipoAbonado = tipoAbonado; responseValidate.valorCliente = valorCliente; responseValidate.codCategoria = codCategoria; responseValidate.desCategoria = desCategoria; responseValidate.wlc03wo_o_cod_sub_seg = wlc03wo_o_cod_sub_seg; responseValidate.awlc03wo_o_desc_sub_seg = awlc03wo_o_desc_sub_seg; responseValidate.FOLIO = FOLIO; responseValidate.MONTO = MONTO; responseValidate.SALDO = SALDO; responseValidate.FECHA_VENCIMIENTO = nuevaFecha; responseValidate.NRO_VENCIDO = NRO_VENCIDO; responseValidate.MONTO_VENCIDO = MONTO_VENCIDO; responseValidate.acarpz3o_flg_arp = acarpz3o_flg_arp; responseValidate.acarpz3o_glosa = acarpz3o_glosa; responseValidate.mso_prioridad = mso_prioridad; responseValidate.mso_glosa_ofer = mso_glosa_ofer.trim(); responseValidate.mso_glosa_cor_ofer = mso_glosa_cor_ofer.trim(); //revisar tipo de campo que genera falla responseValidate.mso_oferta_moneda = mso_oferta_moneda.trim(); responseValidate.mso_precio = mso_precio.trim(); return responseValidate; } var numtelefono = context.getVariable('numtelefono'); var nombreCliente = context.getVariable('nombreCliente'); var primerApellido = context.getVariable('primerApellido'); var segundoApellido = context.getVariable('segundoApellido'); var numAbonado = context.getVariable('numAbonado'); var numIdentidad = context.getVariable('numIdentidad'); var tipoAbonado= context.getVariable('tipoAbonado'); var valorCliente= context.getVariable('valorCliente'); var codCategoria= context.getVariable('codCategoria'); var desCategoria = context.getVariable('desCategoria'); var wlc03wo_o_cod_sub_seg= context.getVariable('wlc03wo_o_cod_sub_seg'); var awlc03wo_o_desc_sub_seg= context.getVariable('awlc03wo_o_desc_sub_seg'); var FOLIO = context.getVariable('FOLIO'); var MONTO = context.getVariable('MONTO'); var SALDO = context.getVariable('SALDO'); var FECHA_VENCIMIENTO = context.getVariable('FECHA_VENCIMIENTO').toString(); var NRO_VENCIDO= context.getVariable('NRO_VENCIDO'); var MONTO_VENCIDO= context.getVariable('MONTO_VENCIDO'); var acarpz3o_flg_arp = context.getVariable('acarpz3o_flg_arp'); var acarpz3o_glosa = context.getVariable('acarpz3o_glosa'); var mso_prioridad = context.getVariable('mso_prioridad'); var mso_glosa_ofer = context.getVariable('mso_glosa_ofer'); var mso_glosa_cor_ofer = context.getVariable('mso_glosa_cor_ofer'); var mso_oferta_moneda = context.getVariable('mso_oferta_moneda'); var mso_precio = context.getVariable('mso_precio'); var responseValidate = validateNulos(numtelefono, nombreCliente, primerApellido, segundoApellido, numAbonado, numIdentidad, tipoAbonado, valorCliente, codCategoria, desCategoria, wlc03wo_o_cod_sub_seg, awlc03wo_o_desc_sub_seg, FOLIO, MONTO, SALDO, FECHA_VENCIMIENTO, NRO_VENCIDO, MONTO_VENCIDO, acarpz3o_flg_arp, acarpz3o_glosa, mso_prioridad, mso_glosa_ofer, mso_glosa_cor_ofer, mso_oferta_moneda, mso_precio); context.setVariable('js_numtelefono', responseValidate.numtelefono); context.setVariable('js_nombreCliente', responseValidate.nombreCliente); context.setVariable('js_primerApellido', responseValidate.primerApellido); context.setVariable('js_segundoApellido', responseValidate.segundoApellido); context.setVariable('js_numAbonado', responseValidate.numAbonado); context.setVariable('js_numIdentidad', responseValidate.numIdentidad); context.setVariable('js_tipoAbonado', responseValidate.tipoAbonado); context.setVariable('js_valorCliente', responseValidate.valorCliente); context.setVariable('js_codCategoria', responseValidate.codCategoria); context.setVariable('js_desCategoria', responseValidate.desCategoria); context.setVariable('js_awlc03wo_o_cod_sub_seg', responseValidate.wlc03wo_o_cod_sub_seg); context.setVariable('js_awlc03wo_o_desc_sub_seg', responseValidate.awlc03wo_o_desc_sub_seg); context.setVariable('js_FOLIO', responseValidate.FOLIO); context.setVariable('js_MONTO', responseValidate.MONTO); context.setVariable('js_SALDO', responseValidate.SALDO); context.setVariable('js_FECHA_VENCIMIENTO', responseValidate.FECHA_VENCIMIENTO); context.setVariable('js_NRO_VENCIDO', responseValidate.NRO_VENCIDO); context.setVariable('js_MONTO_VENCIDO', responseValidate.MONTO_VENCIDO); context.setVariable('js_acarpz3o_flg_arp', responseValidate.acarpz3o_flg_arp); context.setVariable('js_acarpz3o_glosa', responseValidate.acarpz3o_glosa); context.setVariable('js_mso_prioridad', responseValidate.mso_prioridad); context.setVariable('js_mso_glosa_ofer', responseValidate.mso_glosa_ofer); context.setVariable('js_mso_glosa_cor_ofer', responseValidate.mso_glosa_cor_ofer); context.setVariable('js_mso_oferta_moneda', responseValidate.mso_oferta_moneda); context.setVariable('js_mso_precio', responseValidate.mso_precio);
Regards
Based on the error message, it looks like LinkedJSONObject is a List instead of a String, which I cannot tell because the code above only provides the function instead of all the code that invocates the function. Please also provide the section that gets the value from mso_oferta_moneda variable.
If the error has something to do with a list of elements, you could concatenate those values by leveraging the approach presented in this article. https://community.apigee.com/articles/2319/how-to-handle-multi-value-headers-in-javascript.html, so try to concatenate the list with this snippet:
var hdr = context.getVariable('response.header.set-cookie.values')+'';
Dear @Emilio Fallau, please email the stacktrace and the JS code to narrow down this issue.
Sure, upload the complete js.
The error line is the 59 "responseValidate.mso_glosa_cor_ofer = mso_glosa_cor_ofer.trim();//revisar tipo de campo que genera falla"
function validateNulos(numtelefono, nombreCliente, primerApellido, segundoApellido, numAbonado, numIdentidad, tipoAbonado, valorCliente, codCategoria, desCategoria, wlc03wo_o_cod_sub_seg, awlc03wo_o_desc_sub_seg, FOLIO, MONTO, SALDO, FECHA_VENCIMIENTO, NRO_VENCIDO, MONTO_VENCIDO, acarpz3o_flg_arp, acarpz3o_glosa, mso_prioridad, mso_glosa_ofer, mso_glosa_cor_ofer, mso_oferta_moneda, mso_precio) { var responseValidate = {}; if (numtelefono == null || numtelefono == "{}") numtelefono = ""; if (nombreCliente == null || nombreCliente == "{}") nombreCliente = ""; if (primerApellido == null || primerApellido == "{}") primerApellido = ""; if (segundoApellido == null || segundoApellido == "{}") segundoApellido = ""; if (numAbonado == null || numAbonado == "{}") numAbonado = ""; if (numIdentidad == null || numIdentidad == "{}") numIdentidad = ""; if (tipoAbonado == null || tipoAbonado == "{}") tipoAbonado = ""; if (valorCliente == null || valorCliente == "{}") valorCliente = ""; if (codCategoria == null || codCategoria == "{}") codCategoria = ""; if (desCategoria == null || desCategoria == "{}") desCategoria = ""; if (wlc03wo_o_cod_sub_seg == null || wlc03wo_o_cod_sub_seg == "{}") wlc03wo_o_cod_sub_seg = ""; if (awlc03wo_o_desc_sub_seg == null || awlc03wo_o_desc_sub_seg == "{}") awlc03wo_o_desc_sub_seg = ""; if (FOLIO == null || FOLIO == "{}") FOLIO = ""; if (MONTO == null || MONTO == "{}") MONTO = ""; if (SALDO == null || SALDO == "{}") SALDO = ""; if (FECHA_VENCIMIENTO == null || FECHA_VENCIMIENTO == "{}") FECHA_VENCIMIENTO = ""; if (NRO_VENCIDO == null || NRO_VENCIDO == "{}") NRO_VENCIDO = ""; if (MONTO_VENCIDO == null || MONTO_VENCIDO == "{}") MONTO_VENCIDO = ""; if (acarpz3o_flg_arp == null || acarpz3o_flg_arp == "{}") acarpz3o_flg_arp = ""; if (acarpz3o_glosa == null || acarpz3o_glosa == "{}") acarpz3o_glosa = ""; if (mso_prioridad == null || mso_prioridad == "{}") mso_prioridad = ""; if (mso_glosa_ofer == null || mso_glosa_ofer == "{}") mso_glosa_ofer = ""; if (mso_glosa_cor_ofer == null || mso_glosa_cor_ofer == "{}") mso_glosa_cor_ofer = ""; if (mso_oferta_moneda == null || mso_oferta_moneda == "{}") mso_oferta_moneda = ""; if (mso_precio == null || mso_precio == "{}") mso_precio = ""; var monto_pre = Number(MONTO).toString(); //elimina decimal var saldo_pre = Number(SALDO).toString(); //elimina decimal //var folio_pre = Number(FOLIO).toString(); var nuevaFecha = FECHA_VENCIMIENTO.substring(6,8)+FECHA_VENCIMIENTO.substring(4,6)+FECHA_VENCIMIENTO.substring(0,4); responseValidate.numtelefono = numtelefono; responseValidate.nombreCliente = nombreCliente; responseValidate.primerApellido = primerApellido; responseValidate.segundoApellido = segundoApellido; responseValidate.numAbonado = numAbonado; responseValidate.numIdentidad = numIdentidad; responseValidate.tipoAbonado = tipoAbonado; responseValidate.valorCliente = valorCliente; responseValidate.codCategoria = codCategoria; responseValidate.desCategoria = desCategoria; responseValidate.wlc03wo_o_cod_sub_seg = wlc03wo_o_cod_sub_seg; responseValidate.awlc03wo_o_desc_sub_seg = awlc03wo_o_desc_sub_seg; responseValidate.FOLIO = FOLIO; responseValidate.MONTO = MONTO; responseValidate.SALDO = SALDO; responseValidate.FECHA_VENCIMIENTO = nuevaFecha; responseValidate.NRO_VENCIDO = NRO_VENCIDO; responseValidate.MONTO_VENCIDO = MONTO_VENCIDO; responseValidate.acarpz3o_flg_arp = acarpz3o_flg_arp; responseValidate.acarpz3o_glosa = acarpz3o_glosa; responseValidate.mso_prioridad = mso_prioridad; responseValidate.mso_glosa_ofer = mso_glosa_ofer.trim(); responseValidate.mso_glosa_cor_ofer = mso_glosa_cor_ofer.trim(); //revisar tipo de campo que genera falla responseValidate.mso_oferta_moneda = mso_oferta_moneda.trim(); responseValidate.mso_precio = mso_precio.trim(); return responseValidate; } var numtelefono = context.getVariable('numtelefono'); var nombreCliente = context.getVariable('nombreCliente'); var primerApellido = context.getVariable('primerApellido'); var segundoApellido = context.getVariable('segundoApellido'); var numAbonado = context.getVariable('numAbonado'); var numIdentidad = context.getVariable('numIdentidad'); var tipoAbonado= context.getVariable('tipoAbonado'); var valorCliente= context.getVariable('valorCliente'); var codCategoria= context.getVariable('codCategoria'); var desCategoria = context.getVariable('desCategoria'); var wlc03wo_o_cod_sub_seg= context.getVariable('wlc03wo_o_cod_sub_seg'); var awlc03wo_o_desc_sub_seg= context.getVariable('awlc03wo_o_desc_sub_seg'); var FOLIO = context.getVariable('FOLIO'); var MONTO = context.getVariable('MONTO'); var SALDO = context.getVariable('SALDO'); var FECHA_VENCIMIENTO = context.getVariable('FECHA_VENCIMIENTO').toString(); var NRO_VENCIDO= context.getVariable('NRO_VENCIDO'); var MONTO_VENCIDO= context.getVariable('MONTO_VENCIDO'); var acarpz3o_flg_arp = context.getVariable('acarpz3o_flg_arp'); var acarpz3o_glosa = context.getVariable('acarpz3o_glosa'); var mso_prioridad = context.getVariable('mso_prioridad'); var mso_glosa_ofer = context.getVariable('mso_glosa_ofer'); var mso_glosa_cor_ofer = context.getVariable('mso_glosa_cor_ofer'); var mso_oferta_moneda = context.getVariable('mso_oferta_moneda'); var mso_precio = context.getVariable('mso_precio'); var responseValidate = validateNulos(numtelefono, nombreCliente, primerApellido, segundoApellido, numAbonado, numIdentidad, tipoAbonado, valorCliente, codCategoria, desCategoria, wlc03wo_o_cod_sub_seg, awlc03wo_o_desc_sub_seg, FOLIO, MONTO, SALDO, FECHA_VENCIMIENTO, NRO_VENCIDO, MONTO_VENCIDO, acarpz3o_flg_arp, acarpz3o_glosa, mso_prioridad, mso_glosa_ofer, mso_glosa_cor_ofer, mso_oferta_moneda, mso_precio); context.setVariable('js_numtelefono', responseValidate.numtelefono); context.setVariable('js_nombreCliente', responseValidate.nombreCliente); context.setVariable('js_primerApellido', responseValidate.primerApellido); context.setVariable('js_segundoApellido', responseValidate.segundoApellido); context.setVariable('js_numAbonado', responseValidate.numAbonado); context.setVariable('js_numIdentidad', responseValidate.numIdentidad); context.setVariable('js_tipoAbonado', responseValidate.tipoAbonado); context.setVariable('js_valorCliente', responseValidate.valorCliente); context.setVariable('js_codCategoria', responseValidate.codCategoria); context.setVariable('js_desCategoria', responseValidate.desCategoria); context.setVariable('js_awlc03wo_o_cod_sub_seg', responseValidate.wlc03wo_o_cod_sub_seg); context.setVariable('js_awlc03wo_o_desc_sub_seg', responseValidate.awlc03wo_o_desc_sub_seg); context.setVariable('js_FOLIO', responseValidate.FOLIO); context.setVariable('js_MONTO', responseValidate.MONTO); context.setVariable('js_SALDO', responseValidate.SALDO); context.setVariable('js_FECHA_VENCIMIENTO', responseValidate.FECHA_VENCIMIENTO); context.setVariable('js_NRO_VENCIDO', responseValidate.NRO_VENCIDO); context.setVariable('js_MONTO_VENCIDO', responseValidate.MONTO_VENCIDO); context.setVariable('js_acarpz3o_flg_arp', responseValidate.acarpz3o_flg_arp); context.setVariable('js_acarpz3o_glosa', responseValidate.acarpz3o_glosa); context.setVariable('js_mso_prioridad', responseValidate.mso_prioridad); context.setVariable('js_mso_glosa_ofer', responseValidate.mso_glosa_ofer); context.setVariable('js_mso_glosa_cor_ofer', responseValidate.mso_glosa_cor_ofer); context.setVariable('js_mso_oferta_moneda', responseValidate.mso_oferta_moneda); context.setVariable('js_mso_precio', responseValidate.mso_precio);
Regards
Based on the error message, it looks like LinkedJSONObject is a List instead of a String, which I cannot tell because the code above only provides the function instead of all the code that invocates the function. Please also provide the section that gets the value from mso_oferta_moneda variable.
If the error has something to do with a list of elements, you could concatenate those values by leveraging the approach presented in this article. https://community.apigee.com/articles/2319/how-to-handle-multi-value-headers-in-javascript.html, so try to concatenate the list with this snippet:
var hdr = context.getVariable('response.header.set-cookie.values')+'';
diego, we use the proposal solve and works fine.
The issue is when an xml attribute is empty, in the tool that appears like {} but if you count or try to count that variable, his lenght is 1.
thanks for your help
Thanks @Emilio Fallau for letting us know. Please mark the question as resolved.
@Dino FYI.
User | Count |
---|---|
1 | |
1 | |
1 | |
1 | |
1 |