patch-attachment.http 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. POST {{triliumHost}}/etapi/create-note
  2. Authorization: {{authToken}}
  3. Content-Type: application/json
  4. {
  5. "parentNoteId": "root",
  6. "title": "Hello",
  7. "type": "text",
  8. "content": "Hi there!"
  9. }
  10. > {% client.global.set("createdNoteId", response.body.note.noteId); %}
  11. ###
  12. POST {{triliumHost}}/etapi/attachments
  13. Authorization: {{authToken}}
  14. Content-Type: application/json
  15. {
  16. "ownerId": "{{createdNoteId}}",
  17. "role": "file",
  18. "mime": "text/plain",
  19. "title": "my attachment",
  20. "content": "text"
  21. }
  22. > {% client.global.set("createdAttachmentId", response.body.attachmentId); %}
  23. ###
  24. PATCH {{triliumHost}}/etapi/attachments/{{createdAttachmentId}}
  25. Authorization: {{authToken}}
  26. Content-Type: application/json
  27. {
  28. "title": "CHANGED",
  29. "position": 999
  30. }
  31. ###
  32. GET {{triliumHost}}/etapi/attachments/{{createdAttachmentId}}
  33. Authorization: {{authToken}}
  34. > {%
  35. client.assert(response.body.title === "CHANGED");
  36. client.assert(response.body.position === 999);
  37. %}
  38. ###
  39. PATCH {{triliumHost}}/etapi/attachments/{{createdAttachmentId}}
  40. Authorization: {{authToken}}
  41. Content-Type: application/json
  42. {
  43. "ownerId": "root"
  44. }
  45. > {%
  46. client.assert(response.status === 400);
  47. client.assert(response.body.code == "PROPERTY_NOT_ALLOWED");
  48. %}
  49. ###
  50. PATCH {{triliumHost}}/etapi/attachments/{{createdAttachmentId}}
  51. Authorization: {{authToken}}
  52. Content-Type: application/json
  53. {
  54. "title": null
  55. }
  56. > {%
  57. client.assert(response.status === 400);
  58. client.assert(response.body.code == "PROPERTY_VALIDATION_ERROR");
  59. %}