How can I access post body object in a restlet?
# suitescript
a
How can I access post body object in a restlet?
b
should be the single parameter to the post entry point
make sure to go through the descriptions about the effects of the content type
a
Why I can't open these links
All says page not found
b
logged into netsuite?
a
Sorry need login Many thanks
@battk I have tried different ways but no result First of all is this a correct post request fetch(url, { method: "post", contentType: "application/json", body: bodyObject })
If yes
In the restlet ctx.requestBody is empty
b
That fetch isnt using headers correctly
a
Should it be headers: {'Content-Type': 'application/json'}
b
That is one way of doing it
a
What's the other way
a
Ok I've changed that
If the rest is ok
Still the context in the restlet doesn't contain my body bodyObject
b
Whats bodyObject
a
If you see my check request
body: bodyObject
b
As in its value, knowing the name of the variable does little for me
a
bodyObject = {is public: true, isValid: true}
b
its unlikely that a plain object is what you want as the body
there are 6 different types of inputs for the body, using a plain object is equivalent to a USVString created by bodyObject.toString()
a
If I want to use to string()
The return from the l restlet should be a string
Or it's not related
b
use .toString on the value of your object
i doubt its what you are looking for
a
Let's say we have that plain
bodyObj
What's the best way to send the post request
To a restlet
b
learn how to work with json
a
Thanks
And in the restlet
The return type is related
To header content type
Or the body?
b
header