Skip to content

Instantly share code, notes, and snippets.

@AndrewHenderson
Created November 4, 2015 20:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndrewHenderson/60531ad010eef9462890 to your computer and use it in GitHub Desktop.
Save AndrewHenderson/60531ad010eef9462890 to your computer and use it in GitHub Desktop.
Applied Pre-Approvals JSON API Example
//GET /expensereports/1/relationships/applicablepreapprovals HTTP/1.1
//Content-Type: application/vnd.api+json
//Accept: application/vnd.api+json
{
"links": {
"self" : "/expensereports/1/relationships/applicablepreapprovals",
"related": "/expensereports/1/applicablepreapprovals"
},
"data" : [
{"type": "preapprovals", "id": "2"},
{"type": "preapprovals", "id": "3"}
]
};
//GET /expensereports/1?include=applicablepreapprovals HTTP/1.1
//Content-Type: application/vnd.api+json
//Accept: application/vnd.api+json
{
"links" : {
"self": "/expensereports/1?include=applicablepreapprovals"
},
"data" : {
"type" : "expensereports",
"id" : "1",
"attributes" : {
"title": "JSON API paints my bikeshed!"
},
"relationships": {
"applicablepreapprovals": {
"links": {
"self" : "/expensereports/1/relationships/applicablepreapprovals",
"related": "/expensereports/1/applicablepreapprovals"
},
"data" : [
{"type": "preapprovals", "id": "2"},
{"type": "preapprovals", "id": "3"}
]
}
}
},
"included": [{
"type" : "preapprovals",
"id" : "2",
"attributes" : {
"name": "First!"
},
"links" : {
"self": "/preapprovals/2"
}
}, {
"type" : "preapprovals",
"id" : "3",
"attributes" : {
"name": "I like XML better"
},
"links" : {
"self": "preapprovals/3"
}
}]
}
//GET /expensereports/1/applicablepreapprovals HTTP/1.1
//Content-Type: application/vnd.api+json
//Accept: application/vnd.api+json
{
"links" : {
"self": "/expensereports/1/applicablepreapprovals"
},
"data" : [{
"type" : "preapprovals",
"id" : "2",
"attributes" : {
"name": "First!"
},
"links" : {
"self": "/preapprovals/2"
}
}, {
"type" : "preapprovals",
"id" : "3",
"attributes" : {
"name": "I like XML better"
},
"links" : {
"self": "preapprovals/3"
}
}]
}
//GET /preapprovals/1/applypreviews/2 HTTP/1.1
//Content-Type: application/vnd.api+json
//Accept: application/vnd.api+json
{
"links" : {
"self": "/preapprovals/1/applypreviews/2"
},
"data" : {
"type" : "applypreviews",
"id" : "2",
"attributes" : {
"name": "test 1",
"itemTypeTotals": [
{
"paExpenseTypeName": "Parking",
"remainingBalance" : "250",
"spentAmount" : "100"
},
{
"paExpenseTypeName": "Airfare",
"remainingBalance" : "1250",
"spentAmount" : "1100"
}
]
}
}
}
//PATCH /preapprovals/1/relationships/expensereports HTTP/1.1
//Content-Type: application/vnd.api+json
//Accept: application/vnd.api+json
{
"data": [{
"type": "expensereports",
"id" : "2"
}, {
"type": "expensereports",
"id" : "3"
}]
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment