get-inherited-attribute-cloned.http 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. POST {{triliumHost}}/etapi/create-note
  2. Authorization: {{authToken}}
  3. Content-Type: application/json
  4. {
  5. "parentNoteId": "root",
  6. "title": "Hello parent",
  7. "type": "text",
  8. "content": "Hi there!"
  9. }
  10. > {%
  11. client.assert(response.status === 201);
  12. client.global.set("parentNoteId", response.body.note.noteId);
  13. client.global.set("parentBranchId", response.body.branch.branchId);
  14. %}
  15. ### Create inheritable parent attribute
  16. POST {{triliumHost}}/etapi/attributes
  17. Authorization: {{authToken}}
  18. Content-Type: application/json
  19. {
  20. "noteId": "{{parentNoteId}}",
  21. "type": "label",
  22. "name": "mylabel",
  23. "value": "",
  24. "isInheritable": true,
  25. "position": 10
  26. }
  27. > {%
  28. client.assert(response.status === 201);
  29. client.global.set("parentAttributeId", response.body.attributeId);
  30. %}
  31. ### Create child note under root
  32. POST {{triliumHost}}/etapi/create-note
  33. Authorization: {{authToken}}
  34. Content-Type: application/json
  35. {
  36. "parentNoteId": "root",
  37. "title": "Hello child",
  38. "type": "text",
  39. "content": "Hi there!"
  40. }
  41. > {%
  42. client.assert(response.status === 201);
  43. client.global.set("childNoteId", response.body.note.noteId);
  44. client.global.set("childBranchId", response.body.branch.branchId);
  45. %}
  46. ### Create child attribute
  47. POST {{triliumHost}}/etapi/attributes
  48. Authorization: {{authToken}}
  49. Content-Type: application/json
  50. {
  51. "noteId": "{{childNoteId}}",
  52. "type": "label",
  53. "name": "mylabel",
  54. "value": "val",
  55. "isInheritable": false,
  56. "position": 10
  57. }
  58. > {%
  59. client.assert(response.status === 201);
  60. client.global.set("childAttributeId", response.body.attributeId);
  61. %}
  62. ### Clone child to parent
  63. POST {{triliumHost}}/etapi/branches
  64. Authorization: {{authToken}}
  65. Content-Type: application/json
  66. {
  67. "noteId": "{{childNoteId}}",
  68. "parentNoteId": "{{parentNoteId}}"
  69. }
  70. > {%
  71. client.assert(response.status === 201);
  72. client.assert(response.body.parentNoteId == client.global.get("parentNoteId"));
  73. %}
  74. ###
  75. GET {{triliumHost}}/etapi/notes/{{childNoteId}}
  76. Authorization: {{authToken}}
  77. > {%
  78. function hasAttribute(list, attributeId) {
  79. for (let i = 0; i < list.length; i++) {
  80. if (list[i]["attributeId"] === attributeId) {
  81. return true;
  82. }
  83. }
  84. return false;
  85. }
  86. client.log(JSON.stringify(response.body.attributes));
  87. client.assert(response.status === 200);
  88. client.assert(response.body.noteId == client.global.get("childNoteId"));
  89. client.assert(response.body.attributes.length == 2);
  90. client.assert(hasAttribute(response.body.attributes, client.global.get("parentAttributeId")));
  91. client.assert(hasAttribute(response.body.attributes, client.global.get("childAttributeId")));
  92. %}