Error in getting JSON object

Hi Team,

I am trying to implement chatbot mobile application (android / IOS). I tried the code provided in the documentation to fetch the JSON object like :

const request = new Request(‘Juji Chatbot Greeting’, {method: ‘POST’, body: ‘{“firstName”: “John”}’});

                        fetch(request)

                        .then(response => {

                          if (response.status === 200) {

                            return response.json();

                          } else {

                            throw new Error('Something went wrong on api server!');

                          }

                        })

                        .then(response => {

                          console.debug(response);

                          

                        }).catch(error => {

                          console.error(error);

                        });

but I am getting error message as :

Object {
“error”: “Missing first name”,
}

Kindly review and let me know where am I going wrong.

Regards,
Aniket Sinha

Thanks for trying out the documentation. The documentation is now updated to use the correct request payload format. Basically, the body needs to be form data, instead of a JSON object.