How to parse response from custom connector - azure-active-directory

I have an action call on my custom connector that returns JSON with data:
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#users(mail,displayName,department)/$entity",
"mail": "mail#company.com",
"displayName": "First Last",
"department": "DPE-DES-Platform Services"
}
I want to parse this response and store 'department' into a variable that I can use for another action call as a parameter. How would I do this? Sorry if this is elementary, I'm very new to PowerApps.
I have like 10 calls I need to make with graph API and I only want to display the end result, so I need some way to store information into variables. If there was some way I could interact with the information through code that would be great, because I also need to do things like create data structures and modify variables if possible

There is currently no way to directly parse the JSON response in Powerapps . You can use Powerapps with Power automate to parse the JSON response by using Action “Parse JSON”.
Reference: Solved: Parse JSON string in Power APPS - Power Platform Community (microsoft.com)
For the feature you can also upvote the feature request here :
Parse JSON in PowerApps - Power Platform Community (microsoft.com)
For more details on Powerapps : Microsoft Power Apps documentation - Power Apps | Microsoft Docs

You might try using dot (.) notation on the end of your Custom Connector call. Depending on the shape of the actual response, you can parse out a value that way.
Something like:
Set(varDept,
ccCall.GetDept({whatever:criteria}).department
)

Related

CDAP PUBSUB Realtime Pipleine MAP Datatype

Im trying to pull through a pubsub subscription using cdap realtime pipeline.
I can connect the pubsub up but the attributes column is coming through as a MAP datatype and I seen unable to do anything with it (I need the data in it).
The idea is to take that message and place it in a database for further processing.
Is there any way to take the MAP data type and convert it to something useful?
You can convert the column using JavaScript transform plugin.
output.attributes = JSON.stringify(output.attributes);
This will convert the map type to a string.

Custom Activity Data Binding with Salesforce Objects

We can't extract data from the incoming Salesforce Object in the Journey Builder to the Custom Activity we made. We have already followed the syntax that was instructed in your documentation -> https://developer.salesforce.com/docs/atlas.en-us.noversion.mc-apis.meta/mc-apis/how-data-binding-works.htm (under Event Context section).
We are primarily using Postmonger for our Custom Activity, and in our config.json under the inArguments, we input something like below to fetch the data from the Salesforce Object:
"fieldKey": "{{Event." + [ eventDefinitionKey ] + ".Task:Field_Name__c}}"
The eventDefinitionKey we get from the data loaded by triggering the requestedTriggerEventDefinition exposed by the Postmonger.
The resulting inArguments from above would be something like this:
"fieldKey": "{{Event.SalesforceObjacf28b016bf83c75b4926e0ec292eda5.Task:SMS_Content__c}}"
And based from the documentation mentioned previously, that syntax should be enough, yet we cannot retrieve it on our Custom Activity.
Another thing to note is that we can fetch information using the same syntax if the entry object is a Data Extension like below:
"fieldKey": "Event.DEAudience-e56d43c3-e2cf-60f1-fecd-ecf4d358d7b4.Field_Name"
The syntax above work which uses Data Extension is okay, but the one with the Salesforce Object does not.
What are we doing incorrectly here or is not possible entirely?
NOTE: the journey gets triggered by creating a task in Service Cloud
We put " around the eventDefinitionKey and the field name as well, and it works from Salesforce Data sources.
Something like:
"fieldKey": '{{Event."SalesforceObjacf28b016bf83c75b4926e0ec292eda5"."Task:SMS_Content__c"}}'
Note the switch to single quotes and how we're explicitly wrapping those inner attributes with double quotes
Update Oct 2020
Please see this post here which allows you to see the full merge fields of the entire Data Extension (no matter what type it is)

Watson RnR - Creating Ranker using REST API

I am trying out to create an Ranker using the REST API after successfully Adding documents to the collection.
Do I need to use train.py. If so then whats the use of create Ranker API. Also while trying to create RANKER, can you please tell me where do I need to specify cluster id and collection name. Do I need to specify it in metadata.json file.
Any help would be highly appreciated.
See here for an overview of the methods available for training a ranker: https://www.ibm.com/watson/developercloud/doc/retrieve-rank/training_data.html#methods. Using the REST API directly is described under the 'Manually training a ranker' section and is intended for advanced users that might be appending additional columns to the feature vectors that are generated automatically when you use train.py.
The create Ranker REST API call does not take 'cluster id' and 'collection names' as input parameters. It assumes that you've already used the /fcselect REST API call (which does take 'cluster id' and 'collection id') to pre-generate feature vectors similar to what train.py is doing internally. Again, in the advanced use case, you might take these feature vectors and then augment them using some other custom features as described in this blog post: https://medium.com/machine-learning-with-ibm-watson/developing-with-ibm-watson-retrieve-and-rank-part-3-custom-features-826fe88a5c63#.unfm2ocik

What is the best way of querying data with JSON object (through MongoDB) from AngularJS

I have generated a Mean stack app with the angular fullstack generator. In the generated parts of the project, querying data from angular controllers is achieved through a REST api. A typical get endpoint looks like this:
GET /api/things
And this api can be used directly from controller like this:
$http.get('/api/things', { params : {'name': 'xxx'}})
With this approach, i can query data just with string parameters. When i want to query data using a JSON object like this one {'age': {"$gte": 18}}, it does not work since get only support strings as parameters. Now i am not sure what is the best way of querying data with JSON objects. I now have these options in my mind, but i am not sure which may work, or which way i should choose:
1- $http.get('/api/things', { params : encodeURIComponent(JSON.stringify{'age': {"$gte": 18}})})
using this encoding i can pass the JSON object as string. But on the server side i am not sure how i can handle this string. req.query or JSON.parse(req.query) did not work.. This cannot be the right thing to do anyway, since it looks like a hack.
2- Creating another GET api like this:
/api/things/older
calling this api:
$http.get('/api/things/older', { params : {'age': '18'}})
and at the server side implementing the Things.find({'age': {"$gte": req.query.age}})
This is of course not a REST api then.. I don't know if it works at all
3- I have seen some projects where some factories/services are implemented (i have not used one yet). They are injected to controllers, and can be used like this:
var things = Things.query();
However i also don't know whether what i want can be achieved with this approach or this is the right way to do, since as i heard we should only be using our REST api(?).
So the question: What is the best way of querying data with JSON object (through MongoDB) from AngularJS?
Edit: For the 1. option: when i pack my encoded object in another key like this:
$http.get('/api/things', { params : {myQuery : encodeURIComponent(JSON.stringify({'date': {"$gte": new Date().setHours(0,0,0,0)}}))}})
and unpack on server like this:
Thing.find(JSON.parse(decodeURIComponent(req.query.myQuery)))
it works. But it somehow still does not sound right to me.

Salesforce Custom Object Query - REST

I was just wondering if there is a Salesforce url I could query to return only custom objects. I know that you can get all objects using this url:
/services/data/v26.0/sobjects/
However, I don't know the url to just get custom objects, if one exists at all. Any help is appreciated. Thank you.
Force.com Rest API works exactly equal for Custom or Standard objects.
Try this:
/services/data/v26.0/sobjects/MyCustomObjectName__c
MyCustomObjectName__c should be the API object name instead standard name.

Resources