Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

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

Raj_bounteous
Community Advisor
Community Advisor

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.

4 Replies
DavidKangni
Community Advisor
Community Advisor

Hi @Raj_bounteous ,

 

Try this JSON.stringify(result) 

 

Thanks,

David

Raj_bounteous
Community Advisor
Community Advisor
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

Hello @Raj_bounteous 

 

Can you try using this library?

 

https://github.com/abdolence/x2js

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

Raj_bounteous
Community Advisor
Community Advisor

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