create-entities.http 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. POST {{triliumHost}}/etapi/create-note
  2. Authorization: {{authToken}}
  3. Content-Type: application/json
  4. {
  5. "noteId": "forcedId{{$randomInt}}",
  6. "parentNoteId": "root",
  7. "title": "Hello",
  8. "type": "text",
  9. "content": "Hi there!",
  10. "dateCreated": "2023-08-21 23:38:51.123+0200",
  11. "utcDateCreated": "2023-08-21 23:38:51.123Z"
  12. }
  13. > {%
  14. client.assert(response.status === 201);
  15. client.assert(response.body.note.noteId.startsWith("forcedId"));
  16. client.assert(response.body.note.title == "Hello");
  17. client.assert(response.body.note.dateCreated == "2023-08-21 23:38:51.123+0200");
  18. client.assert(response.body.note.utcDateCreated == "2023-08-21 23:38:51.123Z");
  19. client.assert(response.body.branch.parentNoteId == "root");
  20. client.log(`Created note ` + response.body.note.noteId + ` and branch ` + response.body.branch.branchId);
  21. client.global.set("createdNoteId", response.body.note.noteId);
  22. client.global.set("createdBranchId", response.body.branch.branchId);
  23. %}
  24. ### Clone to another location
  25. POST {{triliumHost}}/etapi/branches
  26. Authorization: {{authToken}}
  27. Content-Type: application/json
  28. {
  29. "noteId": "{{createdNoteId}}",
  30. "parentNoteId": "_hidden"
  31. }
  32. > {%
  33. client.assert(response.status === 201);
  34. client.assert(response.body.parentNoteId == "_hidden");
  35. client.global.set("clonedBranchId", response.body.branchId);
  36. client.log(`Created cloned branch ` + response.body.branchId);
  37. %}
  38. ###
  39. GET {{triliumHost}}/etapi/notes/{{createdNoteId}}
  40. Authorization: {{authToken}}
  41. > {%
  42. client.assert(response.status === 200);
  43. client.assert(response.body.noteId == client.global.get("createdNoteId"));
  44. client.assert(response.body.title == "Hello");
  45. // order is not defined and may fail in the future
  46. client.assert(response.body.parentBranchIds[0] == client.global.get("clonedBranchId"))
  47. client.assert(response.body.parentBranchIds[1] == client.global.get("createdBranchId"));
  48. %}
  49. ###
  50. GET {{triliumHost}}/etapi/notes/{{createdNoteId}}/content
  51. Authorization: {{authToken}}
  52. > {%
  53. client.assert(response.status === 200);
  54. client.assert(response.body == "Hi there!");
  55. %}
  56. ###
  57. GET {{triliumHost}}/etapi/branches/{{createdBranchId}}
  58. Authorization: {{authToken}}
  59. > {%
  60. client.assert(response.status === 200);
  61. client.assert(response.body.branchId == client.global.get("createdBranchId"));
  62. client.assert(response.body.parentNoteId == "root");
  63. %}
  64. ###
  65. GET {{triliumHost}}/etapi/branches/{{clonedBranchId}}
  66. Authorization: {{authToken}}
  67. > {%
  68. client.assert(response.status === 200);
  69. client.assert(response.body.branchId == client.global.get("clonedBranchId"));
  70. client.assert(response.body.parentNoteId == "_hidden");
  71. %}
  72. ###
  73. POST {{triliumHost}}/etapi/attributes
  74. Content-Type: application/json
  75. Authorization: {{authToken}}
  76. {
  77. "attributeId": "forcedAttributeId{{$randomInt}}",
  78. "noteId": "{{createdNoteId}}",
  79. "type": "label",
  80. "name": "mylabel",
  81. "value": "val",
  82. "isInheritable": true
  83. }
  84. > {%
  85. client.assert(response.status === 201);
  86. client.assert(response.body.attributeId.startsWith("forcedAttributeId"));
  87. client.global.set("createdAttributeId", response.body.attributeId);
  88. %}
  89. ###
  90. GET {{triliumHost}}/etapi/attributes/{{createdAttributeId}}
  91. Authorization: {{authToken}}
  92. > {%
  93. client.assert(response.status === 200);
  94. client.assert(response.body.attributeId == client.global.get("createdAttributeId"));
  95. %}
  96. ###
  97. POST {{triliumHost}}/etapi/attachments
  98. Content-Type: application/json
  99. Authorization: {{authToken}}
  100. {
  101. "ownerId": "{{createdNoteId}}",
  102. "role": "file",
  103. "mime": "plain/text",
  104. "title": "my attachment",
  105. "content": "my text"
  106. }
  107. > {%
  108. client.assert(response.status === 201);
  109. client.global.set("createdAttachmentId", response.body.attachmentId);
  110. %}
  111. ###
  112. GET {{triliumHost}}/etapi/attachments/{{createdAttachmentId}}
  113. Authorization: {{authToken}}
  114. > {%
  115. client.assert(response.status === 200);
  116. client.assert(response.body.attachmentId == client.global.get("createdAttachmentId"));
  117. client.assert(response.body.role == "file");
  118. client.assert(response.body.mime == "plain/text");
  119. client.assert(response.body.title == "my attachment");
  120. %}