cancel
Showing results for 
Search instead for 
Did you mean: 

Error in XSJS (JSON parse error - "Invalid Character"

sameer_mehta
Participant
0 Kudos

Hello,

I have created ODATA service in HANA Cloud trial account which is working fine, I am able to see the data in JSON format but when I am calling the service through XSJS, it is giving JSON error "Invalid Character". The error is coming while using JSON.Parse() function.

On further investigation, I tried to display the ODATA response, it is displaying: "An error occurred while handling your request".

I also tried to save the certificate in XS admin Trust manager, still the issue is not resolved.

May be I am missing some setting or doing things incorrectly. Request you to please help me with the resolution.

pfefferf
Active Contributor
0 Kudos

Can you please explain for what you are using JSON.parse?

sameer_mehta
Participant
0 Kudos

Actually, I am following the steps from link "https://blogs.sap.com/2017/11/29/building-chatbot-using-sap-cloud-platform-part-1/" to build chat bot application and following is the code:

var JSONObj = JSON.parse(odata_Response);
          var botResponse;
     
          if (JSONObj.d.results.length > 0) 
          {
            botResponse = "Agents List: ";
            for (var i = 0; i < JSONObj.d.results.length; i++) 
            {
              botResponse += " ";
              // Concatenate First & Last Agents names
              botResponse += JSONObj.d.results[i].FIRST_NAME 
                              + JSONObj.d.results[i].LAST_NAME;
            }
          } 
          else 
          {
            botResponse = "No data Found";
          }

Please suggest if there is better option to do this.
pfefferf
Active Contributor
0 Kudos

And what is the content of the odata_Response?

sameer_mehta
Participant
0 Kudos

The content of odata_Response is list of contents of Agents table which has column Agent ID, First Name, Last Name.

If I execute the Odata link manually in the browser it shows me the list of Agents but through XSJS I tried to display the content, it showed "An error occurred while handling your request".

Do I need to upload certificate in Trust manager?

Accepted Solutions (0)

Answers (0)