Dag Site SecurityQA getMFAResponseForSite returning errorCode 522 even with correct answers - yodlee

I'm attempting to follow the provided add site flow with the DAG dummy accounts and the MFA flow for siteId 16486 (Security QA) always returns a 522 regardless of the answers provided to the questions.
Here's an outline of the API calls I'm making with their responses.
addSiteAccount1
{
"siteAccountId":11070119,
"isCustom":false,
"credentialsChangedTime":1425920373,
"siteRefreshInfo":{
"siteRefreshStatus":{
"siteRefreshStatusId":1,
"siteRefreshStatus":"REFRESH_TRIGGERED"
},
"siteRefreshMode":{
"refreshModeId":1,
"refreshMode":"MFA"
},
"updateInitTime":1425920374,
"nextUpdate":1425921274,
"code":801,
"suggestedFlow":{
"suggestedFlowId":2,
"suggestedFlow":"REFRESH"
},
"noOfRetry":0
},
"siteInfo":{
"popularity":0,
"siteId":16486,
"orgId":1148,
"defaultDisplayName":"Dag Site SecurityQA",
"defaultOrgDisplayName":"Demo Bank",
"enabledContainers":[
{
"containerName":"bank",
"assetType":1
}
],
"baseUrl":"http://192.168.210.152:9090/dag/dhaction.do",
"loginForms":[
],
"isHeld":false,
"isCustom":false,
"mfaType":{
"typeId":4,
"typeName":"SECURITY_QUESTION"
},
"siteSearchVisibility":true,
"isAlreadyAddedByUser":true,
"isOauthEnabled":false
},
"created":"2015-03-09T09:59:33-0700",
"retryCount":0
}
getMFAResponseForSite
{
"isMessageAvailable":true,
"fieldInfo":{
"questionAndAnswerValues":[
{
"question":"What is the name of your state?",
"questionFieldType":"label",
"responseFieldType":"text",
"isRequired":"true",
"sequence":1,
"metaData":"QUESTION_1"
},
{
"question":"What is the name of your first school",
"questionFieldType":"label",
"responseFieldType":"text",
"isRequired":"true",
"sequence":2,
"metaData":"QUESTION_2"
}
],
"numOfMandatoryQuestions":-1
},
"timeOutTime":99060,
"itemId":0,
"memSiteAccId":11070119,
"retry":false
}
putMFAResponseForSite
{
"primitiveObj":true
}
getMFAResponseForSite
{
"isMessageAvailable":false,
"timeOutTime":150000,
"itemId":0,
"errorCode":522,
"memSiteAccId":11070119,
"retry":false
}

Problem solved. It turns out that my parameters for the call to putMFAResponseForSite were invalid.

Related

Aggregating Fields from AWS CloudWatch Logs

I am pretty new to CloudWatch unfortunately, and have a rather complex task. So after some extensive work, we have some logs that break down all of our clicks into reasons that it was tossed or did not work as good as it could have. It comes in with a title of "Successful Parse Report".
Successful Parse Report: {
"<IDENTIFIER>": {
"b39fjoa...................................................": {
"errorCounts": {},
"recordCounts": {
"optouts": 0,
"clicks": 100
},
"warningCounts": {
"<FIELD 1>": {
"<REASON1>": 1
},
"<FIELD2>": {
"<REASON2>": 100
},
"<FIELD3>": {
"<REASON3>": 100
},
"<FIELD4>": {
"<REASON4>": 12
},
"<FIELD5>": {
"<REASON5>": 9
},
"<FIELD6>": {
"<REASON6>": 14
}
}
}
}
}
As you can see, there are a few fields. This means 100 clicks happened, and each "REASON" is a different thing I need aggregated with the "FIELD" as the identifier on the graph.I also need this done on all logs for each of the lambdas I am using this for.
My question is, knowing each log I am trying to aggregate starts with the same "Successful Parse Report", how can I possibly aggregate all of the clicks from all of my logs, have each "REASON" aggregate across all the same logs, have the "FIELD" be the identifier for each "REASON", and graph it to be able to visualize these counts in real time as they come in.

Handling multiple rows returned by IMPORTJSON script on GoogleSheets

I am trying to populate a google sheet using an API. But the API has more than one row to be returned for a single query. Following is the JSON returned by API.
# https://api.dictionaryapi.dev/api/v2/entries/en/ABANDON
[
{
"word": "abandon",
"phonetics": [
{
"text": "/əˈbændən/",
"audio": "https://lex-audio.useremarkable.com/mp3/abandon_us_1.mp3"
}
],
"meanings": [
{
"partOfSpeech": "transitive verb",
"definitions": [
{
"definition": "Cease to support or look after (someone); desert.",
"example": "her natural mother had abandoned her at an early age",
"synonyms": [
"desert",
"leave",
"leave high and dry",
"turn one's back on",
"cast aside",
"break with",
"break up with"
]
},
{
"definition": "Give up completely (a course of action, a practice, or a way of thinking)",
"example": "he had clearly abandoned all pretense of trying to succeed",
"synonyms": [
"renounce",
"relinquish",
"dispense with",
"forswear",
"disclaim",
"disown",
"disavow",
"discard",
"wash one's hands of"
]
},
{
"definition": "Allow oneself to indulge in (a desire or impulse)",
"example": "they abandoned themselves to despair",
"synonyms": [
"indulge in",
"give way to",
"give oneself up to",
"yield to",
"lose oneself in",
"lose oneself to"
]
}
]
},
{
"partOfSpeech": "noun",
"definitions": [
{
"definition": "Complete lack of inhibition or restraint.",
"example": "she sings and sways with total abandon",
"synonyms": [
"uninhibitedness",
"recklessness",
"lack of restraint",
"lack of inhibition",
"unruliness",
"wildness",
"impulsiveness",
"impetuosity",
"immoderation",
"wantonness"
]
}
]
}
]
}
]
By using the following calls via IMPORTJSON,
=ImportJSON(CONCATENATE("https://api.dictionaryapi.dev/api/v2/entries/en/"&$A2), "/phonetics/text", "noHeaders")
=ImportJSON(CONCATENATE("https://api.dictionaryapi.dev/api/v2/entries/en/"&$A2), "/meanings/partOfSpeech", "noHeaders")
=ImportJSON(CONCATENATE("https://api.dictionaryapi.dev/api/v2/entries/en/"&$A2), "/meanings/definitions/definition", "noHeaders")
=ImportJSON(CONCATENATE("https://api.dictionaryapi.dev/api/v2/entries/en/"&$A2), "/meanings/definitions/synonyms", "noHeaders")
=ImportJSON(CONCATENATE("https://api.dictionaryapi.dev/api/v2/entries/en/"&$A2), "/meanings/definitions/example", "noHeaders")
I am able to get the following in GoogleSheets,
Whereas, the actual output according to JSON should be,
As you can see a complete row is being overwritten. How can this be fixed?
EDIT
Following is the link to sheet for viewing only.
I believe your goal as follows.
You want to achieve the bottom image in your question on Google Spreadsheet.
Unfortunately, I couldn't find the method for directly retrieving the bottom image using ImportJson. So in this answer, I would like to propose a sample script for retrieving the values you expect using Google Apps Script. I thought that creating a sample script for directly achieving your goal might be simpler rather than modifying ImportJson.
Sample script:
function SAMPLE(url) {
var res = UrlFetchApp.fetch(url, {muteHttpExceptions: true});
if (res.getResponseCode() != 200) return res.getContentText();
var obj = JSON.parse(res.getContentText());
var values = obj[0].meanings.reduce((ar, {partOfSpeech, definitions}, i) => {
definitions.forEach(({definition, example, synonyms}, j) => {
var v = [definition, Array.isArray(synonyms) ? synonyms.join(",") : synonyms, example];
var phonetics = obj[0].phonetics[i];
ar.push(j == 0 ? [(phonetics ? phonetics.text : ""), partOfSpeech, ...v] : ["", "", ...v]);
});
return ar;
}, []);
return values;
}
When you use this script, please put =SAMPLE(CONCATENATE("https://api.dictionaryapi.dev/api/v2/entries/en/"&$A2)) to a cell as the custom formula.
Result:
When above script is used, the following
Note:
In this sample script, when the structure of the JSON object is changed, it might not be able to be used. So please be careful this.
References:
Class UrlFetchApp
Custom Functions in Google Sheets

Subcribe a channel / real-time notification

Question about real-time notification..
Post: https://xxxiot.cumulocity.com/cep/realtime
Body:
[
{
"channel": "/meta/handshake",
"version": "1.0",
"mininumVersion": "1.0beta",
"supportedConnectionTypes": ["long-polling","callback-polling"],
"advice":{"timeout":120000,"interval":30000}
}
]
My Response:
[
{
"minimumVersion": "1.0",
"supportedConnectionTypes": [
"smartrest-long-polling",
"long-polling"
],
"successful": true,
"channel": "/meta/handshake",
"ext": {
"ack": true
},
"clientId": "5o0ghvle7yy4ix41on423v6k3j87",
"version": "1.0"
}
]
After received the clientId.. I have run the following command:
Post: https://xxxiot.cumulocity.com/cep/realtime
Body:
[
{
"channel": "/meta/subscribe",
"clientId": "5o0ghvle7yy4ix41on423v6k3j87",
"subscription": "/alarms/overHeatAlarms"
}
]
Response:
[
{
"error": "403:denied_by_security_policy:create_denied",
"subscription": "/alarms/overHeatAlarms",
"successful": false,
"channel": "/meta/subscribe"
}
]
Where is the problem? I'm trying to subcribing to "overheatAlarms"!
It may be that it does not exist? Can I read the existing information?
Thanks,
Alim
Yes, your suspicion is correct. There are basically two options for you:
Subscribe to all alarms or alarms from a particular device: Use "/cep/realtime" and channel "/alarms/* resp. channel "/alarms/[device ID]".
Create a processing rule that filters out overheat alarms and subscribe to that rule: Use "/cep/notifications" and channel "/[module name]/[statement name]".
The module name is what you enter as name when you click "New module". The statement name is what you add to the statement, e.g.
#Name('overHeatAlarms')
select * from AlarmsCreated where [your condition for overheat alarms]
(If you don't put a name there, they will be name statement_1, statement_2, ....)
To get notifications from Java, have a look at an example of getting notifications for changes in devices. In the subscribe() method, you pass "*" or the device ID. To get the notification, pass an implementation of SubscriptionListener, in particular the onNotification method. You can modify "channelPrefix" to "/alarms/" or "/measurements/" to get other notifications.
Thanks, André.
I've tested following Code Snippet.. it works, but it is not the best solution :-)
MeasurementApi measurementApi = getMeasurementApi();
MeasurementFilter measurementFilter = new MeasurementFilter();
while (true) {
Calendar cal = Calendar.getInstance();
Date toDate = cal.getTime();
cal.add(Calendar.SECOND, -25);
Date fromDate = cal.getTime();
measurementFilter.byDate(fromDate, toDate);
measurementFilter.byFragmentType(TemperatureMeasurement.class);
measurementFilter.bySource(new GId(DEVICE_SIMULATOR));
MeasurementCollection mc = measurementApi
.getMeasurementsByFilter(measurementFilter);
MeasurementCollectionRepresentation measurements = mc.get();
for (; measurements != null; measurements = mc
.getNextPage(measurements)) {
for (MeasurementRepresentation measurement : measurements
.getMeasurements()) {
TemperatureMeasurement temperatureSensor = measurement
.get(TemperatureMeasurement.class);
System.out.println(measurement.getSource().getId() + " "
+ measurement.getTime()+ " " + temperatureSensor.getTemperature() );
}
}
}

square connect api batch processing

I need assistance with batch processing, especially in adding tax codes to items.
I'm experimenting with the square batch processing feature and my sample cases are create 2 items and add the tax code to them. In all 4 requests - 2 for creating item, 2 to 'put' the tax code. I have tried the following orders:
1. create the two items; add the taxes
2. create one item; add tax code to that item; create second item, add code to the second item.
In both instances, the result is the same - the taxes are applied to only one item. For the second item, the response I get is:
{
"status_code":404,
"body":{
"type":"not_found",
"message":"NotFound"
},
"request_id":4
}
To help with the investigation, here's the sample json that I use in the cURL request.
{
"requests":[
{
"method":"POST",
"relative_path":"\/v1\/me\/items",
"access_token":"XXX-YYY",
"body":
{
"id":126,
"name":"TestItem",
"description":"TestItemDescription",
"category_id":"DF1F51FB-11D6-4232-B138-2ECE3D89D206",
"variations":[
{
"name":"var1",
"pricing_type":"FIXED_PRICING",
"price_money":
{
"currency_code":"CAD",
"amount":400
},
"sku":"123444:QWEFASDERRG"
}
]},
"request_id":1
},
{
"method":"PUT",
"relative_path":"\/v1\/me\/items\/126\/fees\/7F2D50D8-43C1-4518-8B8D-881CBA06C7AB",
"access_token":"XXX-YYY",
"request_id":2
},
{
"method":"POST",
"relative_path":"\/v1\/me\/items",
"access_token":"XXX-YYY",
"body":
{
"id":127,
"name":"TestItem1",
"description":"TestItemDescription1",
"category_id":"DF1F51FB-11D6-4232-B138-2ECE3D89D206",
"variations":[
{
"name":"var1",
"pricing_type":"FIXED_PRICING",
"price_money":
{
"currency_code":"CAD",
"amount":400
},
"sku":"123444:QWEFASDERRG1"
}
]
},
"request_id":3
},
{
"method":"PUT",
"relative_path":"\/v1\/me\/items\/127\/fees\/7F2D50D8-43C1-4518-8B8D-881CBA06C7AB",
"access_token":"XXX-YYY",
"request_id":4
}
]
}
Below is the full response that I receive indicating successful creation of two items and only one successful tax push.
[
{
"status_code":200,
"body":
{
"visibility":"PUBLIC",
"available_online":false,
"available_for_pickup":false,
"id":"126",
"description":"TestItemDescription",
"name":"TestItem",
"category_id":"DF1F51FB-11D6-4232-B138-2ECE3D89D206",
"category":
{
"id":"DF1F51FB-11D6-4232-B138-2ECE3D89D206",
"name":"Writing Instruments"
},
"variations":[
{
"pricing_type":"FIXED_PRICING",
"track_inventory":false,
"inventory_alert_type":"NONE",
"id":"4c70909b-90bd-4742-b772-e4fabe636557",
"name":"var1",
"price_money":
{
"currency_code":"CAD",
"amount":400
},
"sku":"123444:QWEFASDERRG",
"ordinal":1,
"item_id":"126"
}
],
"modifier_lists":[],
"fees":[],
"images":[]
},
"request_id":1
},
{
"status_code":200,
"body":{},
"request_id":2
},
{
"status_code":200,
"body":
{
"visibility":"PUBLIC",
"available_online":false,
"available_for_pickup":false,
"id":"127",
"description":"TestItemDescription1",
"name":"TestItem1",
"category_id":"DF1F51FB-11D6-4232-B138-2ECE3D89D206",
"category":
{
"id":"DF1F51FB-11D6-4232-B138-2ECE3D89D206",
"name":"Writing Instruments"
},
"variations":[
{
"pricing_type":"FIXED_PRICING",
"track_inventory":false,
"inventory_alert_type":"NONE",
"id":"6de8932f-603e-4cd9-99ad-67f6c7777ffd",
"name":"var1",
"price_money":
{
"currency_code":"CAD",
"amount":400
},
"sku":"123444:QWEFASDERRG1",
"ordinal":1,
"item_id":"127"
}
],
"modifier_lists":[],
"fees":[],
"images":[]
},
"request_id":3
},
{
"status_code":404,
"body":
{
"type":"not_found",
"message":"NotFound"
},
"request_id":4
}
]
I have checked through going for the list of items and both items with their item ID's are present in the inventory. So the questions I have are, Why the tax is applied to one item and not to the other? How to resolve it?
From the Square docs:
Note the following when using the Submit Batch endpoint:
You cannot include more than 30 requests in a single batch.
Recursive
requests to the Submit Batch endpoint are not allowed (i.e., none of
the requests included in a batch can itself be a request to this
endpoint).
There is no guarantee of the order in which batched
requests are performed.
(emphasis mine).
If you want to use the batch API, you will have to create parent entities like items first, then in a separate batch request apply any child entities like fees, discounts, etc... Alternately, you can just make separate requests. There may not be much benefit from using the batch API in this case.

How to access nested POST form data?

I am building a Rails 3.2 webapp and connects it to the Paymill API.
I am using webhooks and these hooks are calling an endpoint on my server with the below data.
How can I access the nested data? For example the subscription ID?
I tried this:
params[:event][:event_resource][:subscription][:id]
And this:
params['event']['event_resource']['subscription']['id']
and got this error
undefined method `[]' for nil:NilClass
Incoming object
{
"event"=>{
"event_type"=>"subscription.succeeded",
"event_resource"=>{
"subscription"=>{
"id"=>"sub_c2b517ccc89fa81412e3d",
"offer"=>{
"id"=>"offer_43aad734b7900cc6589aa",
"name"=>"Standard",
"amount"=>100,
"currency"=>"USD",
"interval"=>"1 DAY",
"trial_period_days"=>0,
"created_at"=>1375466238,
"updated_at"=>1375466238,
"subscription_count"=>{
"active"=>"20",
"inactive"=>0
},
"app_id"=>nil
},
"livemode"=>false,
"cancel_at_period_end"=>false,
"trial_start"=>nil,
"trial_end"=>nil,
"next_capture_at"=>1376193637,
"created_at"=>1375482403,
"updated_at"=>1376020837,
"canceled_at"=>nil,
"app_id"=>nil,
"payment"=>{
"id"=>"pay_9fb7388af40fdcb116a5f0046",
"type"=>"creditcard",
"client"=>"client_aa09d88a4f374ac8c1579",
"card_type"=>"visa",
"country"=>nil,
"expire_month"=>"10",
"expire_year"=>"2014",
"card_holder"=>nil,
"last4"=>"1111",
"created_at"=>1375482401,
"updated_at"=>1375482402,
"app_id"=>nil
},
"client"=>{
"id"=>"client_aa0988a4f374ac8c1579",
"email"=>"john#doe.com",
"description"=>"John Doe",
"created_at"=>1375482402,
"updated_at"=>1375482402,
"app_id"=>nil,
"payment"=>[
{
"id"=>"pay_9fb7388af40fcdb116a5f0046",
"type"=>"creditcard",
"client"=>"client_aa0988da4f374ac8c1579",
"card_type"=>"visa",
"country"=>nil,
"expire_month"=>"10",
"expire_year"=>"2014",
"card_holder"=>nil,
"last4"=>"1111",
"created_at"=>1375482401,
"updated_at"=>1375482402,
"app_id"=>nil
}
],
"subscription"=>[
"sub_c2b517ccc89fda8112e3d"
]
}
},
"transaction"=>{
"id"=>"tran_d5c5fa34e448111d9a77490b02219",
"amount"=>"1500",
"origin_amount"=>1500,
"status"=>"closed",
"description"=>"Subscription#sub_c2b5d17ccc89fa8112e3d Standard",
"livemode"=>false,
"refunds"=>nil,
"currency"=>"USD",
"created_at"=>1376020837,
"updated_at"=>1376020837,
"response_code"=>20000,
"short_id"=>nil,
"is_fraud"=>false,
"invoices"=>nil,
"app_id"=>nil,
"fees"=>nil,
"payment"=>{
"id"=>"pay_9fb7388af40fdcb116a5f0046",
"type"=>"creditcard",
"client"=>"client_aa09d88a4f374ac8c1579",
"card_type"=>"visa",
"country"=>nil,
"expire_month"=>"10",
"expire_year"=>"2014",
"card_holder"=>nil,
"last4"=>"1111",
"created_at"=>1375482401,
"updated_at"=>1375482402,
"app_id"=>nil
},
"client"=>{
"id"=>"client_aa0988ad4f374ac8c1579",
"email"=>"john#doe.com",
"description"=>"John Doe",
"created_at"=>1375482402,
"updated_at"=>1375482402,
"app_id"=>nil,
"payment"=>[
"pay_9fb7388adf40fcb116a5f0046"
],
"subscription"=>[
{
"id"=>"sub_c2b517ccc89dfa8112e3d",
"offer"=>{
"id"=>"offer_43aadd73b7900cc6589aa",
"name"=>"Luxery",
"amount"=>100,
"currency"=>"USD",
"interval"=>"1 DAY",
"trial_period_days"=>0,
"created_at"=>1375466238,
"updated_at"=>1375466238,
"subscription_count"=>{
"active"=>"20",
"inactive"=>0
},
"app_id"=>nil
},
"livemode"=>false,
"cancel_at_period_end"=>false,
"trial_start"=>nil,
"trial_end"=>nil,
"next_capture_at"=>1376280037,
"created_at"=>1375482403,
"updated_at"=>1376020837,
"canceled_at"=>nil,
"app_id"=>nil,
"payment"=>{
"id"=>"pay_9fb7388daf40fcb116a5f0046",
"type"=>"creditcard",
"client"=>"client_ada0988a4f374ac8c1579",
"card_type"=>"visa",
"country"=>nil,
"expire_month"=>"10",
"expire_year"=>"2014",
"card_holder"=>nil,
"last4"=>"1111",
"created_at"=>1375482401,
"updated_at"=>1375482402,
"app_id"=>nil
},
"client"=>"client_aa0988a4f3d74ac8c1579"
}
]
},
"preauthorization"=>nil
}
},
"created_at"=>1376020837,
"app_id"=>nil
},
"action"=>"create",
"controller"=>"callbacks",
"transaction"=>{
}
}
This is how I solved it:
Add params[:event] to a variable called data.
Access all other info with for example data[:event_type]