Labs/Joey/CommunicationProtocol: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 1: Line 1:
Below are the Machine-to-machine communication protocols we currently use for Joey server and addon/J2ME client. All HTTP request parameters (e.g., attr=value) are POST parameters.
Below are the Machine-to-machine communication protocols we currently use for Joey server and addon/J2ME client. If the request is successfully executed, the server returns HTTP code 200 with data in the response body (or, empty body if there is no data). If the server encounters an error, it returns custom HTTP codes as discussed below, and an empty body.




Line 6: Line 6:
/users/login
/users/login


Request (all required):
Request:
   * rest=1
   * rest=1
   * data[User][username]=<username>
   * data[User][username]=<username>
   * data[User][password]=<password>
   * data[User][password]=<password>


Response (one of the following in text format):
Success Response:
   * Success: Integer user ID (>0)
   * HTTP 200 with empty body
  * Fail: -2 (not activated)
 
   * Fail: -3 (generic error e.g., wrong password)
Error HTTP Status Code:
   * Numeric code "-1" is reserved for "user not logged in" error
   * 512 Login Error
   * 513 User not Activated


----
----
Line 21: Line 22:
/uploads/index
/uploads/index


Request (all required):
Request:
   * rest=1
   * rest=1
   * limit=<number of entries to be returned>
   * limit=<number of entries to be returned> (optional)
   * start=<limit * start is the first entry to be returned>
   * start=<limit * start is the first entry to be returned> (optional)




Response: The first line is always a numeric return code. Value "-1" indicates the user session has expired. You need to re-login and then load the /uploads/index again. A positive (or zero) integer "n" indicates the number of items in this index. The items are organized as follows (i iterates from 1 to n):
Success Response: The first line is always a numeric return code. A positive (or zero) integer "n" indicates the number of items in this index. The items are organized as follows (i iterates from 1 to n):
   title.i=<the title>
   title.i=<the title>
   referrer.i=<referrer URL>
   referrer.i=<referrer URL>
Line 34: Line 35:
   type.i=<MIME type for the transcode content at /files/view/id>
   type.i=<MIME type for the transcode content at /files/view/id>
   preview.i=<Base64 encoded preview data -- always image/png>
   preview.i=<Base64 encoded preview data -- always image/png>
Error HTTP Status Code:
  * 511 No Active Session


----
----
Line 39: Line 43:
/uploads/delete/id
/uploads/delete/id


Request (all required):
Request:
   * The "id" in the URL
   * The "id" in the URL
   * rest=1
   * rest=1


Response:
Success Response:
   * Success: 0
   * HTTP 200 with empty body
   * User not logged in: -1
 
   * Generic failure (e.g., wrong user): -2
Error HTTP Status Code:
   * 511 No Active Session
  * 515 Not Permitted for This User
   * 514 Cannot Delete
      
      
----
----
Line 53: Line 60:


This one is currently uses multi-part file upload. We need a different URL for the mobile client. Perhaps /uploads/j2me_add ??
This one is currently uses multi-part file upload. We need a different URL for the mobile client. Perhaps /uploads/j2me_add ??
Request:
  * Multi-part file upload or content upload with the correct MIME type
Success Response:
  * HTTP 200 with empty body
Error HTTP Status Code:
  * 511 No Active Session
  * 517 Out of Space for Upload
  * 518 Generic Upload Error


----
----
Line 58: Line 76:
/files/view/id
/files/view/id


Request (all required):
Request:
   * The "id" in the URL
   * The "id" in the URL


Response:
Success Response:
  * HTTP code 200
   * MIME type in HTTP header
   * MIME type in HTTP header
   * Binary content in body
   * Binary content in body


Error cases (both for MIME type text/HTML):
Error HTTP Status Code:
   * code "-1" for "user not logged in"
   * 511 No Active Session
   * code "-2" for other errors
  * 515 Not Permitted for This User
   * 516 File Access Error


----
----
Line 73: Line 93:
/files/view/id/preview
/files/view/id/preview


Request (all required):
Request:
   * The "id" in the URL
   * The "id" in the URL


Response:
Success Response:
  * HTTP code 200
   * MIME type in HTTP header
   * MIME type in HTTP header
   * Binary content in body
   * Binary content in body


Error cases (both for MIME type text/HTML):
Error HTTP Status Code:
   * code "-1" for "user not logged in"
   * 511 No Active Session
   * code "-2" for other errors
  * 515 Not Permitted for This User
   * 516 File Access Error


----
----
Line 88: Line 110:
/files/view/id/original
/files/view/id/original


Request (all required):
Request:
   * The "id" in the URL
   * The "id" in the URL


Response:
Success Response:
  * HTTP code 200
   * MIME type in HTTP header
   * MIME type in HTTP header
   * Binary content in body
   * Binary content in body


Error cases (both for MIME type text/HTML):
Error HTTP Status Code:
   * code "-1" for "user not logged in"
   * 511 No Active Session
   * code "-2" for other errors
  * 515 Not Permitted for This User
   * 516 File Access Error
10

edits