質問

I'm developing a REST server using RESTlet framework. I'm in the process of receiving POST requests with a JSON object in the body. But I'm lost on how can I access the JSON object that comes in the POST body. So I'm asking for some direction here on how to access the body of the POST request.

This POST requests will be made by the clients using my server.

My server is running on android.

EDIT:

My class is extending Restlet, I know how to do it if it was extending ServerResource, but in this case I can't change from extending Restlet to ServerResource

役に立ちましたか?

解決

You can simply do something like this in a ServerResource:

@Post
public void yourMethod(Representation rep) {...}

Or...

If you are extending Restlet and overriding the handle(Request, Response) method or similar then you can call getEntity() on the request to get the Representation.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top