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
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

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

Avatar

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.

1 Accepted Solution

Avatar

Correct answer by
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. 

View solution in original post

0 Replies

Avatar

Community Advisor

Hi @Raj_Ganta ,

 

Try this JSON.stringify(result) 

 

Thanks,

David

Avatar

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.

Avatar

Community Advisor

Hello @Raj_Ganta 

 

Can you try using this library?

 

https://github.com/abdolence/x2js

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

Avatar

Correct answer by
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.