cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Help us improve the PTC Community by taking this short Community Survey! X

how to remove "Unable To Parse JSON Request" error?

Ru
14-Alexandrite
14-Alexandrite

how to remove "Unable To Parse JSON Request" error?

hello,

getting an error "Unable To Parse JSON Request" while adding device id through mashup.

i have one code which gives me existing device id in database and i my another code is validation service created for the mashup where i wanted to compare device id present in database with the validation service input device id.

Now when i click on add band button it gives me an error "Unable To Parse JSON Request" i dont know why i am getting this error. below is my validation service code:-

// result: INFOTABLE dataShape: "checkBandDeviceDataDS"
let result1 = me.checkBandDeviceId({
device_id: device_id /* INTEGER */
});

if(device_id == "" || device_id == null){
result = 'Please enter device id';
}
else if(result1.device_id == device_id){
result = 'This device id is already exist';
}
else {
result = '';
}

above code is running perfectly when i run the personal code but it's not running through mashup, please suggest some solution on this, below is snapshot for your better understanding 

 

122_0-1614069046648.png

 

 

ACCEPTED SOLUTION

Accepted Solutions
nmilleson
17-Peridot
(To:Ru)

I run into this issue occasionally when I try and pass Integers into a service in a mashup.  My workaround has been to change the service input type to a String and then do a parseInt() in the service.

View solution in original post

6 REPLIES 6
nmilleson
17-Peridot
(To:Ru)

I run into this issue occasionally when I try and pass Integers into a service in a mashup.  My workaround has been to change the service input type to a String and then do a parseInt() in the service.

Ru
14-Alexandrite
14-Alexandrite
(To:nmilleson)

@nmilleson ,

can you please give me the an example how to use parseInt() function in service ? i have tried to use this function but it's not working...so please help me out

nmilleson
17-Peridot
(To:Ru)

@Ru 

 

parseInt accepts a string and an optional radix... here's an example:

 

var device_id = parseInt(device_id_string);

 

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/parseInt

 

 

Ru
14-Alexandrite
14-Alexandrite
(To:nmilleson)

hi @nmilleson ,

my validation service is running correct but when m trying to run through mashup it shows an error "Execution error in service script [AddBandValidation] :: Unable To Convert From java.lang.String to INTEGER"

below is my code and mashup error snapshot please check for your better understanding:-

// result: INFOTABLE dataShape: "checkBandDeviceDataDS"
 let result = me.checkBandDeviceId({
device_id: device_ID /* INTEGER */
});
if(device_ID == null){
result = 'Please enter device id';
}
else if(result.device_id == device_ID){
result = 'This device id is already exist';
}
else {
result = '';
}     

the above code is running properly but when m clicking on add new band button in mashup then it is giving me an error "Execution error in service script [AddBandValidation] :: Unable To Convert From java.lang.String to INTEGER"

122_0-1614689040260.png

 

For error Execution error in service script [AddBandValidation] :: Unable To Convert From java.lang.String to INTEGER, please check in the scripts code, there might be some place that has String type assign to Integer type. Add some logger.warn("") to the scripts to narrow down on which line the code is failing and debug the issue.

slangley
23-Emerald II
(To:Ru)

Hi @Ru.

 

If you feel that your question has been answered, please mark the appropriate response as the Accepted Solution for the benefit of others with the same question.

 

Regards.

 

--Sharon

Announcements


Top Tags