Texts¶
httpkom.texts
¶
texts_get(text_no)
async
¶
Get a text.
Note: The body will only be included in the response if the content type is text.
Request:
Responses:
Text exists:
HTTP/1.0 200 OK
{
"body": "räksmörgås",
"recipient_list": [
{
"recpt": {
"conf_no": 14506
"name": "Oskars Testperson",
},
"type": "to",
"loc_no": 29,
}
],
"author": {
"pers_no": 14506,
"pers_name": "Oskars Testperson"
},
"creation_time": "2013-11-30T15:58:06Z",
"comment_in_list": [],
"content_type": "text/x-kom-basic",
"text_no": 19680717,
"comment_to_list": [],
"subject": "jaha"
}
Text does not exist:
Example:
textstats_get(text_no)
async
¶
textstats_batch()
async
¶
texts_get_body(text_no)
async
¶
Get the body of text, with the content type of the body set in the HTTP header. Useful for creating img-tags in HTML and specifying this URL as source.
If the content type is text, the text will be recoded to UTF-8. For other types, the content type will be left untouched.
Request:
Responses:
Text exists:
Text does not exist:
Example:
texts_create()
async
¶
Create a text.
Request:
POST /<server_id>/texts/ HTTP/1.0
{
"body": "räksmörgås",
"subject": "jaha",
"recipient_list": [ { "type": "to", "recpt": { "conf_no": 14506 } } ],
"content_type": "text/x-kom-basic",
"comment_to_list": [ { "type": "footnote", "text_no": 19675793 } ]
}
Responses:
Text was created:
HTTP/1.0 201 Created
Location: http://localhost:5001/<server_id>/texts/19724960
{
"text_no": 19724960,
}
Example text:
curl -v -X POST -H "Content-Type: application/json" \
-d '{ "body": "räksmörgås", \
"subject": "jaha", \
"recipient_list": [ { "recpt": { "conf_no": 14506 }, "type": "to" } ], \
"content_type": "text/x-kom-basic", \
"comment_to_list": [ { "type": "footnote", "text_no": 19675793 } ] }' \
"http://localhost:5001/lyskom/texts/"
Example image:
curl -v -X POST -H "Content-Type: application/json" \
-d '{ "body": "<base64>", \
"subject": "jaha", \
"recipient_list": [ { "recpt": { "conf_no": 14506 }, "type": "to" } ], \
"content_type": "image/jpeg", \
"content_encoding": "base64", \
"comment_to_list": [ { "type": "footnote", "text_no": 19675793 } ] }' \
"http://localhost:5001/lyskom/texts/"