Usergrid: Queries not accepted in GET requests - apigee

Using Postman when I issue a get request to my Usergrid backend I get a response back. For example:
When I run:
https://api.usergrid.com/gss/sandbox/summaries
I get a response:
{
"action": "get",
"application": "6e9204f0-71da-11e4-9a58-bd53db9c149b",
"params": {},
"path": "/summaries",
"uri": "https://api.usergrid.com/gss/sandbox/summaries",
"entities": [
{
"uuid": "7cd5c98a-7b16-11e4-9085-b5397738dcd5",
"type": "summary",
"created": 1417629724184,
"modified": 1417629993800,
"accountId": "123123",
"accounts": [
{
"id": "123123",
"type": "Individual",
"category": "Prepaid",
"numberOfLines": 2,
"balance": {...
However when I run the request with a query:
https://api.usergrid.com/gss/sandbox/summaries?ql=select * where id=123123
I get :
"action": "get",
"application": "6e9204f0-71da-11e4-9a58-bd53db9c149b",
"params": {
"ql": [
"select * where id=123123"
]
},
"path": "/summaries",
"uri": "https://api.usergrid.com/gss/sandbox/summaries",
"entities": [],
"timestamp": 1418766878176,
"duration": 7,
"organization": "gss",
"applicationName": "sandbox",
"count": 0
I want to be able to get the complete response when I pass in an 'id' in the query as it is coming from my UI & get the response. Any ideas?
-S

Your id property is a sub-key of accounts - when dealing with objects, you can use dot notation to reference sub-keys, like account.id. Unfortunately in your case, because you're using an array ([]) of accounts in a single entity (not an {} object), those are not queryable. I did notice though that the same property exists under accountId. You could try:
https://api.usergrid.com/gss/sandbox/summaries?ql=select * where accountId=123123
If not, I'd recommend you look at using a new collection to maintain your list of accounts, and use connections to manage the relationships between the entities.

Related

Searching Google Calendar extendedProperties does not return any match

I am using Google Calendar API v3 in to search for a specific property/value. I was able to successfully create the extended property as you can see here:
{
"kind": "calendar#events",
"etag": "\"p33cf16d5ousve0g\"",
"summary": "Ryan's Personal Camptivities",
"updated": "2022-04-29T15:11:23.687Z",
"timeZone": "America/Los_Angeles",
"accessRole": "owner",
"defaultReminders": [
{
"method": "popup",
"minutes": 10
}
],
"nextSyncToken": "CNjwmaXHufcCENjwmaXHufcCGAUg67Ly0wE=",
"items": [
{
"extendedProperties": {
"private": {
"OutlookEventGO": "AAMkADNkODYzZGQ5LWY5ZGItNGFjZi1iMWMzLTI3MmY0YmIxMTcxNQBGAAAAAAC5E322QQ7ORLEmN7zGNq0zBwAUl432Bg61QItQhHQwcosuAAAAAAENAAAUl432Bg61QItQhHQwcosuAAF6QI0zAAA="
}
]
}
but when I go to search for the extendedProperty, i get no response:
https://www.googleapis.com/calendar/v3/calendars/ryan%40camptivities.com/events?privateExtendedProperty=OutlookEventGO%3DAAMkADNkODYzZGQ5LWY5ZGItNGFjZi1iMWMzLTI3MmY0YmIxMTcxNQBGAAAAAAC5E322QQ7ORLEmN7zGNq0zBwAUl432Bg61QItQhHQwcosuAAAAAAENAAAUl432Bg61QItQhHQwcosuAAF6QI0zAAA%3D&
{
"kind": "calendar#events",
"etag": "\"p33cf16d5ousve0g\"",
"summary": "Ryan's Personal Camptivities",
"updated": "2022-04-29T15:11:23.687Z",
"timeZone": "America/Los_Angeles",
"accessRole": "owner",
"defaultReminders": [
{
"method": "popup",
"minutes": 10
}
],
"nextSyncToken": "CNjwmaXHufcCENjwmaXHufcCGAUg67Ly0wE=",
"items": []
}
Is this because of the encoding of the extendedProperty value? If so, how do I fix this? If not, what am I doing wrong?
Thanks in advance...
The problem is the = at the end of your privateExtendedProperty value
This seems to create issues when it comes to the url encoding of the property.
If you use a property value without an =, e.g.
AAMkADNkODYzZGQ5LWY5ZGItNGFjZi1iMWMzLTI3MmY0YmIxMTcxNQBGAAAAAAC5E322QQ7ORLEmN7zGNq0zBwAUl432Bg61QItQhHQwcosuAAAAAAENAAAUl432Bg61QItQhHQwcosuAAF6QI0zAAA
you can perfectly retrieve it with out request:
https://www.googleapis.com/calendar/v3/calendars/ryan%40camptivities.com/events?privateExtendedProperty=OutlookEventGO%3DAAMkADNkODYzZGQ5LWY5ZGItNGFjZi1iMWMzLTI3MmY0YmIxMTcxNQBGAAAAAAC5E322QQ7ORLEmN7zGNq0zBwAUl432Bg61QItQhHQwcosuAAAAAAENAAAUl432Bg61QItQhHQwcosuAAF6QI0zAAA
Your privateExtendedProperty seems to be encoded, so if the = is important for you to decode the value back, you will need to add it back programatically when require.

Logic App > Cosmos PartitionKey Not Matching Error

I'm scared to put this out there because it should be so easy and I am facing the same issue as the post here, here and here and I have tried each of the answers to no avail. Below is the current Resulting Input (redacted) and Related CodeView of the inputs.
The Result
{
"method": "post",
"headers": {
"x-ms-documentdb-raw-partitionkey": "\"2020\""
},
"path": "/dbs/xxxx/colls/smtp/docs",
"host": {
"connection": {
"name": "/subscriptions/..."
}
},
"body": {
"category": [
[
"cat facts"
]
],
"email": "example#test.com",
"event": "processed",
"id": "yada",
"partitionKey": "\"2020\"",
"sg_event_id": "yada yada",
"sg_message_id": "yada",
"smtp-id": "yada",
"timestamp": 1604345542
}
}
The Code View
{
"inputs": {
"body": {
"category": [
"#items('For_each')['category']"
],
"email": "#items('For_each')['email']",
"event": "#items('For_each')['event']",
"id": "#items('For_each')['sg_message_id']",
"partitionKey": "\"#{formatDateTime(utcNow(),'yyyy')}\"",
"sg_event_id": "#items('For_each')['sg_event_id']",
"sg_message_id": "#items('For_each')['sg_message_id']",
"smtp-id": "#items('For_each')['smtp-id']",
"timestamp": "#items('For_each')['timestamp']"
},
"headers": {
"x-ms-documentdb-raw-partitionkey": "\"#{formatDateTime(utcNow(),'yyyy')}\""
}
}
The error I'm getting is the usual one - PartitionKey extracted from document doesn't match the one specified in the header
I just can't see what I'm missing here now.
Thanks all.
First, as Matias comments, check your partition key path.
Then, change this code "partitionKey": "\"#{formatDateTime(utcNow(),'yyyy')}\"", to "partitionKey": "#{formatDateTime(utcNow(),'yyyy')}", in your document.
It works fine on my side:

Getting all profiles from Google Analytics API

I'm trying to get all profiles using ~all option with this endpoint
https://www.googleapis.com/analytics/v3/management/accounts/~all/webproperties/~all/profiles
It doesn't return all profiles due to ~all for accounts. If I include account ID instead of ~all, then it returns profiles based on that account id - which are missing when used with ~all option.
https://www.googleapis.com/analytics/v3/management/accounts/89478503/webproperties/~all/profiles
Am I doing something wrong or is this GA API bug?
I sugst you look into using account summaries list
GET https://www.googleapis.com/analytics/v3/management/accountSummaries
This will return all the account information for a user.
{
"kind": "analytics#accountSummaries",
"username": "me#gmail.com",
"totalResults": 15,
"startIndex": 1,
"itemsPerPage": 1000,
"items": [
{
"id": "59183475",
"kind": "analytics#accountSummary",
"name": "Cube Analytics",
"webProperties": [
{
"kind": "analytics#webPropertySummary",
"id": "UA-59183475-1",
"name": "Cube Analytics",
"internalWebPropertyId": "93305066",
"level": "STANDARD",
"websiteUrl": "XXXXXXX",
"profiles": [
{
"kind": "analytics#profileSummary",
"id": "115455750",
"name": "Alaternate",
"type": "WEB"
},
{
"kind": "analytics#profileSummary",
"id": "97191919",
"name": "All Web Site Data",
"type": "WEB"
},
{
"kind": "analytics#profileSummary",
"id": "178538323",
"name": "MobileView",
"type": "APP"
}
]
}, ]
}
By using this call you should only need to make one call and get all of the information back.

Marketo - How to save complex object in Lead Database?

I was asked to store leads like below in Marketo's lead database through rest api "POST /rest/v1/leads.json".
{
"action": "createOnly",
"lookupField": "email",
"input": [{
"email": "kjashaedd-1#klooblept.com",
"firstName": "Kataldar-1",
"postalCode": "04828",
"property": [{
"type": "land",
"status": "available"
},
{
"type": "car",
"status": "sold out"
},
{
"type": "bike",
"status": "sold out"
},
{
"type": "laptops",
"status": "available"
}
]
},
{
"email": "kjashaedd-2#klooblept.com",
"firstName": "Kataldar-2",
"postalCode": "04828",
"property": [{
"type": "land",
"status": "sold out"
},
{
"type": "car",
"status": "available"
},
{
"type": "bike",
"status": "sold out"
},
{
"type": "laptops",
"status": "available"
}
]
}
]
}
Input field is not in flat json structure. What could be the best approach? Do I really need to use custom objects in this case? Can I dump "property" object as it is in the lead database and use velocity script to parse it ?
If 'Property' is a custom object, you'll want to call that separately for the record and associated the record with that object via the custom object API
So you can push (create) the record first and then associate (add) the custom object to the record.
You can create a List<Dictionary<string,object>> in C# and retrieve the data and then store it using Entity Framework.
I am considering .Net framework in this case

JAGQL - Why do I need an id for a post call?

I'm using JAGQL to build a JSON API compatible express server. My database behind it is MongoDB (jsonapi-store-mongodb). I posted my question here as well: https://github.com/holidayextras/jsonapi-store-mongodb/issues/59
According to the JAGQL documentation, https://jagql.github.io/pages/project_setup/resources.html#generateid,
I am told that
generateId
By default, the server autogenerates a UUID for resources which are created without specifying an ID. To disable this behavior (for example, if the database generates an ID by auto-incrementing), set generateId to false. If the resource's ID is not a UUID, it is also necessary to specify an id attribute with the correct type. See /examples/resorces/autoincrement.js for an example of such a resource.
But when I send a POST request to one of my resources, I get this:
"jsonapi": {
"version": "1.0"
},
"meta": {},
"links": {
"self": "/myresource"
},
"errors": [
{
"status": "403",
"code": "EFORBIDDEN",
"title": "Param validation failed",
"detail": [
{
"message": "\"id\" is required",
"path": [
"id"
],
"type": "any.required",
"context": {
"key": "id",
"label": "id"
}
}
]
}
]
What am I missing?
See here for more details: https://github.com/jagql/framework/issues/106
In your resource definition, you want to add primaryKey: 'uuid':
{
resource: 'things',
handlers,
primaryKey: 'uuid',
attributes: {
...
}
}

Resources