Usergrid: How to delete add on Metadata from Usergrid entities

136 views Asked by At

I created an entity on usergrid but I find that usergrid tacks on additional data in the JSON, that I really don't want appearing in the API layer. For example here is my entity:

{
  **"uuid": "7cd5c98a-7b16-11e4-9085-b5397738dcd5",
  "type": "summaries",
  "created": 1417629724184,
  "modified": 1417629993800,**
  "accountId": "123123",
  "accounts": [
    {
      "id": "123123",
      "type": "Individual",
      "category": "Prepaid",

The fields uuid/type/created/modified is not what I want to pull although usergrid tacks it along. I can write logic on the receiving side which parses this out, but we don't want to write any kind of business logic in the Proxy. How can I suppress this behaviour?

1

There are 1 answers

2
Michael Bissell On BEST ANSWER

Unfortunately Usergrid isn't really good for an Open API and you should put it behind a management layer like Apigee Edige. Log into your Apigee account and click on Create and Manage APIs.

In there you can manipulate the JSON payload by extracting blocks or individual elements (like below where I grab either all accounts or just the ID for the first account in the list)

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ExtractVariables async="false" continueOnError="false" enabled="true" name="Extract-Account-Response">
    <DisplayName>Extract Account Response</DisplayName>
    <FaultRules/>
    <Properties/>
    <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
    <JSONPayload>
        <Variable name="allComments">
            <JSONPath>$.accounts</JSONPath>
        </Variable>
        <Variable name="account0">
            <JSONPath>$.accounts[0].id</JSONPath>
        </Variable>
    </JSONPayload>
    <Source clearPayload="false">commentResponse</Source>
</ExtractVariables>

If you're not using Apigee you'll still need to put some kind of programatic facade in front of Usergrid to manipulate the responses.