ai-one / braindocsclient

The goal of the BraindocsClient is to provide a utility for BrainDocs users to interact with the BrainDocs API.
1 stars 1 forks source link

Add ability to POST text to BrainDocs #2

Open kmanninen opened 9 years ago

kmanninen commented 9 years ago

Tomi,

I haven't completed the BrainDocs API update yet, however I wanted to give you a heads up about what I'm planning to do. I plan to implement a POST function for a library that will accept an array of JSON objects. It will return a libraryId that can then be used to monitor the status of the library (whether it is ready to analyze or not).

The API function will be:

Request:

POST /library
Content-Type: application/json

[{"id":"123", "text":"This is testunit 1."}, {"id":"abc", "text":"This is textunit 2."}, ...]

Response:

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{"ok": true, "libraryId": "507f1f77bcf86cd799439011"}

I will let you know when complete. -Kurt

kmanninen commented 9 years ago

Quick Modification

The POST example was incorrect. The data being passed should be "id" and "doc" where by the "id" is the unique id from the client (whatever the client is using to distinguish the documents) and the "doc" is the text of the documents that the client wishes to send to the BrainDocs library. So it should be:

Request:

POST /library
Content-Type: application/json

[{"id": "123", "doc": "This is the text of document 123."}, {"id": "abc", "doc": "This is the text of document abc."}, ...]

Response:

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{"ok": true, "libraryId": "507f1f77bcf86cd799439011"}
kmanninen commented 9 years ago

I just promoted the new POST command to our development server. The POST parameters are as follows:

Request:

POST /library
Content-Type: application/json
     {
          "name":"Name of new library",
          "description":"Description of new library", 
          "docs": [
           {
              "id":"123",
               "filename":"doc123",
               "doc":"This is the text for document 123."
            },
            {
               "id":"abc",
               "filename":"docabc",
               "doc":"This is the text for document abc."
            }
          ]
}