Scripted rest api PUT and PATCH, empty request.body
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2023 04:44 AM
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:
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2023 12:15 AM
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 '{}'.