function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sagar 12Sagar 12 

why data is not reflecting in post method

Hi,

I am new to integration and learning from trailhead.
I came accross this doubt in REST callout chapter

Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('https://th-apex-http-callout.herokuapp.com/animals');
request.setMethod('POST');
request.setHeader('Content-Type', 'application/json;charset=UTF-8');
// Set the body as a JSON object
request.setBody('{"name":"mighty moose"}');
HttpResponse response = http.send(request);
// Parse the JSON response
if (response.getStatusCode() != 201) {
    System.debug('The status code returned was not expected: ' +
        response.getStatusCode() + ' ' + response.getStatus());
} else {
    System.debug(response.getBody());
}

this code should append the "mighty moose" to my endpoint data.
but when i open endpoint in browser data remains same.

What is going on here? am I missing any point here.

Regards,
Sagar
Ashish DevAshish Dev
the data will not be stored on endpoint that is heroku server, but it will return you back the data which is mighty moose, and you will find this in debug logs.