tahrir icon indicating copy to clipboard operation
tahrir copied to clipboard

Identifying the errors

Open tjdharamsi opened this issue 10 years ago • 7 comments

tjdharamsi avatar Jun 11 '14 17:06 tjdharamsi

Hey, I have done sample code for /identity and /message uri.. Is this the way we need to proceed?

tjdharamsi avatar Jul 12 '14 21:07 tjdharamsi

Hello all , I wrote this variation which aims to respond on the type of request made ; If used using browser then it will return in html else if using curl on the type of request either json or html it would respond;

But it has no error but on running the server, it just shows the status " Not Found" Restlet Default page; Could anyone help me figure out what's going wrong?

tjdharamsi avatar Jul 22 '14 14:07 tjdharamsi

Is there a way to check the type of the response which is expected along with the type of request?

tjdharamsi avatar Jul 25 '14 20:07 tjdharamsi

Tejas: for each request, a specific response on expected. what exactly is expected is determined by the API that we wrote. Go check that document, it is king.

QuiteStochastic avatar Jul 26 '14 19:07 QuiteStochastic

What I meant was for example in class TahrirRestlet in /message we've used if request.getmethod.getName.equals("Get") on the similar lines i was looking for a method similar to this to check for response for what kind of MediaType is expected along with the request. If the response is Html or Json. Presently we set the type of response as part of setEntity(response,Mediatype)

tjdharamsi avatar Jul 26 '14 19:07 tjdharamsi

Well according to the API doc, when we receive a GET in /messages, we must return a JSON that looks like this:

{ "messages":[ { "author_pubkey":"...", "author_nick":"sanity", "message_id":124, "message_hash":"4z...E8", "content":"hi" }, { "author_pubkey":"...", "author_nick":"some_other_Guy", "message_id":534, "message_hash":"dsfgdfsgsdf", "content":"teeheehe" } ] }

So when we set the response, we just set the Mediatype to JSON. I don't see why we shouldn't do this. There's no method to check what the response should be, the requester doesn't give that to us, it just assumes we've read the API doc and have implemented correctly.

QuiteStochastic avatar Jul 26 '14 19:07 QuiteStochastic

True!!! I was just trying out new stuffs with REST like chrome extension POSTMAN so was trying new thing with it. The above thing was just a example. Whatever we've done till now is exactly as per the API doc written. I was just exploring new things around the REST and Restlet.

tjdharamsi avatar Jul 26 '14 19:07 tjdharamsi