Sending PATCHes
You can use a request tool, such as Postman, to ensure PATCHes are well-formed and to review the structure of the response payloads. For more information on Postman, see Requests and responses.
Send a PATCH using Postman
Procedure
- In Postman, start a new request by clicking the + to the right of the Launchpad tab.
-
Specify Basic Auth authorization using user
aapplegate
and passwordgw
. - Under the Untitled Request label, make sure that PATCH is selected.
-
In the Enter request URL field, enter the URL for the server and
the endpoint.
- For example, to patch activity pc:2 on an instance of PolicyCenter on your
machine, enter:
http://localhost:8180/pc/rest/common/v1/activities/cc:2
- For example, to patch activity pc:2 on an instance of PolicyCenter on your
machine, enter:
-
Specify the request payload.
- In the first row of tabs (the one that starts with Params), click Body.
- In the row of radio buttons, select raw.
- At the end of the row of radio buttons, change the drop-down list value from Text to JSON.
- Paste the request payload into the text field underneath the radio buttons.
- Click Send. The response payload appears below the request payload.
Tutorial: PATCH an activity
This tutorial assumes you have set up your environment with Postman and the correct sample data set. For more information, see Tutorial: Set up your Postman environment.
In this tutorial, you will find an open activity from the sample data. You will then update the activity's subject and priority.
Tutorial steps
- In Postman, start a new request by clicking the + to the right of the Launchpad tab.
- Specify Basic Auth authorization using user
aapplegate
and passwordgw
. - Query for all open activities by entering the following call and clicking
Send:
- GET
http://localhost:8180/pc/rest/common/v1/activities?filter=status:eq:open
- GET
- For the first activity in the response payload that is assigned to Andy/Alice Applegate,
note the following information:
- Activity ID
- Priority
- Subject
- On the same tab, enter the following call, but do not click Send
yet:
- PATCH
http://localhost:8180/pc/rest/common/v1/activities/<activityID>
- PATCH
- Specify the request payload.
- In the first row of tabs (the one that starts with Params), click Body.
- In the row of radio buttons, select raw.
- At the end of the row of radio buttons, change the drop-down list value from Text to JSON.
- Paste the following into the text field underneath the radio buttons. For subject,
specify the original subject with an additional "!".
{ "data": { "attributes": { "subject" : "<originalSubject>!", "priority": { "code": "low" } } } }
- Click Send. The response payload appears below the request payload.
Checking your work
- View the modified activity in PolicyCenter.
- Log on to PolicyCenter as the user
aapplegate
. In the left-hand side bar, click My Activities. PolicyCenter shows the My Activities screen, which shows the open activities assigned to Alice. - Click the Priority column to sort the activities in reverse priority order.
- Log on to PolicyCenter as the user
The patched activity (whose priority is now Low) should be at or near the top of the list. The patched activity will have a subject ending with an "!".