how to convert query result into JSON to use a body to API call | Adobe Higher Education
Skip to main content
Raj_Ganta-1
Level 5
May 23, 2021
Risolto

how to convert query result into JSON to use a body to API call

  • May 23, 2021
  • 3 risposte
  • 2143 visualizzazioni

Hi,

 

I am trying to make an API call and need query results in the request body. I am finding it difficult to convert the result into a JSON body. Any help is appreciated. Thank you.

Questo argomento è stato chiuso alle risposte.
Migliore risposta di Raj_Ganta-1

I tried it in different way and it worked. Created an array with quotes and somehow stringify was throwing error. Didnt use that. 

3 risposte

DavidKangni
Community Advisor
Community Advisor
May 24, 2021

Hi @raj_ganta-1 ,

 

Try this JSON.stringify(result) 

 

Thanks,

David

David Kangni
Raj_Ganta-1
Level 5
May 24, 2021
I need to remove the root node and as well the the next node after that to make sure body is in proper format. when I try to use removeChild , it is throwing up error.
Manoj_Kumar
Community Advisor
Community Advisor
May 28, 2021

Hello @raj_ganta-1 

 

Can you try using this library?

 

https://github.com/abdolence/x2js

It has an option to parse with namespaces and root nodes.

Manoj     Find me on LinkedIn
Raj_Ganta-1
Raj_Ganta-1AutoreRisposta
Level 5
May 30, 2021

I tried it in different way and it worked. Created an array with quotes and somehow stringify was throwing error. Didnt use that.