Skip to main content
Raj_Ganta-1
Level 5
May 23, 2021 4:45 AM UTC
Solved

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

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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Raj_Ganta-1
Raj_Ganta-1Accepted solution
Level 5
May 30, 2021 7:27 AM UTC

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

4 replies

DavidKangni
Adobe Champion and Community Advisor
Adobe Champion and Community Advisor
May 24, 2021 2:29 PM UTC

Hi @raj_ganta-1 ,

 

Try this JSON.stringify(result) 

 

Thanks,

David

Translate
David Kangni
Raj_Ganta-1
Level 5
May 24, 2021 5:52 PM UTC
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.
Translate
Manoj_Kumar
Community Advisor
Community Advisor
May 28, 2021 12:05 AM UTC

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.

Translate
Manoj  | https://themartech.pro
Raj_Ganta-1
Raj_Ganta-1AuthorAccepted solution
Level 5
May 30, 2021 7:27 AM UTC

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

Translate