[Bps-public-commit] rt-extension-rest2 branch, rt-extension-rest2-docs, created. 1.01-1-ge5bb7b5

Craig Kaiser craig at bestpractical.com
Tue Feb 6 11:34:40 EST 2018


The branch, rt-extension-rest2-docs has been created
        at  e5bb7b543f83ea921cd2d361cb7abce8dc74b51d (commit)

- Log -----------------------------------------------------------------
commit e5bb7b543f83ea921cd2d361cb7abce8dc74b51d
Author: Craig Kaiser <craig at bestpractical.com>
Date:   Tue Feb 6 11:32:13 2018 -0500

    Add examples of JSON curl POST from tests

diff --git a/lib/RT/Extension/REST2.pm b/lib/RT/Extension/REST2.pm
index b7e2a7b..0b2cdcb 100644
--- a/lib/RT/Extension/REST2.pm
+++ b/lib/RT/Extension/REST2.pm
@@ -263,6 +263,14 @@ controls available in response bodies rather than hardcoding URLs.
 
     POST /ticket
         create a ticket; provide JSON content
+        curl -X POST -H "Content-Type: application/json" -d
+            '{"subject": "Ticket creation using REST",
+             "From": "test at bestpractical.com",
+             "To": "rt at localhost", "Queue": "General",
+             "Content": "Testing ticket creation using REST API."}'
+             -u 'root:password' 'REST/2.0/ticket?Queue=1'
+
+        result: '{"id":"8","_url":"REST/2.0/ticket/8","type":"ticket"}'
 
     GET /ticket/:id
         retrieve a ticket
@@ -270,6 +278,12 @@ controls available in response bodies rather than hardcoding URLs.
     PUT /ticket/:id
         update a ticket's metadata; provide JSON content
 
+        curl -X PUT -H "Content-Type: application/json" -d
+            '{"Subject": "Ticket update using REST", "Priority": 42}'
+            -u 'root:password' 'REST/2.0/ticket/8'
+
+        result: '["Ticket 8: Priority changed from (no value) to '42'","Ticket 8: Subject changed from (no value) to 'Ticket update using REST'"]'
+
     DELETE /ticket/:id
         set status to deleted
 
@@ -344,6 +358,13 @@ controls available in response bodies rather than hardcoding URLs.
     POST /assets
         search for assets using L</JSON searches> syntax
 
+        curl -X POST -H "Content-Type: application/json" -d
+            '{"Name": "Asset creation using REST", "Catalog": "General assets",
+            "Content": "Testing asset creation using REST API."}'
+            -u 'root:password' 'REST/2.0/asset'
+
+        results: '{"type":"asset","id":"8","_url":"http://localhost:8080/REST/2.0/asset/8"}'
+
     POST /asset
         create an asset; provide JSON content
 

-----------------------------------------------------------------------


More information about the Bps-public-commit mailing list