The CreatorCon Call for Content is officially open! Get started here.

Scripted rest api PUT and PATCH, empty request.body

JG6
Kilo Guru

Hello Community,

 

I've got the scripted api resource:

(function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
    gs.warn("request.body = " + JSON.stringify(request.body)); // returns '{}'
})(request, response);

 

Whatever I try, request.body remains an empty object. Both with regular Python requests and Postman. The url is correct because the logs are updated as expected. And I am pretty certain the request is correct:

 

JG6_0-1675082428225.png

 

Being so basic, I must be missing something obvious. But I can't seem to find it. The logs contain no errors either.

 

Is there something I can check ?

 

THX

1 REPLY 1

JG6
Kilo Guru

The rookie mistake that I had to use "request.body.data" instead of "request.body". 🙂

 

Found the obvious: request.body is not a simple object, but rather an instance of RESTAPIRequestBody. I've got confused by the fact that JSON.stringify(request.body) resulted in '{}'.