DeleteButton triggers "Incorrect Element" - admin-on-rest

I'm implementing an asp.net core API with admin-on-rest.
A custom REST client communicates to the API endpoints, but the mapping is fairly standard.
When I try to implement a into the interface, the deletion of elements works fine. Still, I get an error on every edit or deletion view for an element with the following text: "Incorrect Element". The console is empty, and everything works as expected.
What causes the error - and how can I solve this?
I've attached a screenshot of the error popup.
Screenshot of the error
Update 1:
Here is the code of my custom REST client: customrestclient gist and the included fetch.js: fetch.js

Double check your custom restClient returns at least the id of the deleted resource inside a data object.

I was finally able to fix the issue. One of my API endpoints returned a list instead of a single element for one of my ReferenceInput-elements.
This was the content response before my change:
[{
"languageId": 2,
"id": 2,
"name": "Danish",
"isoCode": "dan"
}]
And this is the correct response, that does not trigger the error:
{
"languageId": 2,
"id": 2,
"name": "Danish",
"isoCode": "dan"
}

Related

why couchdb and fauxton don't work correctly in windows 10?

Current situation:
After installing couchdb on windows 10 using the apache-couchdb-2.3.1.msi installer and configure its operation as a simple node with the data
User: Admin (It's for testing only) Password: Pass (Too insecure? It's for testing only!) Port: 5984 Ip: 127.0.0.1
The installation was verified: http://127.0.0.1:5984/_utils/#/verifyinstall
When creating a "test" database it is created correctly When creating a new document it is created correctly
Problem: When adding information to the created document and pressing the "Save Changes" button
Nothing happens, changes are not saved
Unmodified document:
{"_id": "e940717f486026242e9b5d9cd80023d2", "_rev": "1-967a00dff5e02add41819138abb3284d"}
Document modified (Changes are not saved)
{"_id": "e940717f486026242e9b5d9cd80023d2", "_rev": "1-967a00dff5e02add41819138abb3284d" "data": "Hello World"}
The button only works when the document has not undergone changes or when I delete the aggregated data "data" I have also tried adding the comma "," at the end of each line
{"_id": "e940717f486026242e9b5d9cd80023d2", "_rev": "1-967a00dff5e02add41819138abb3284d", "data": "Hello World",}
The same without any results, I tried using firefox and chrome, I tried to disable plugins and addons in those browsers
It seems that your JSON is not correct.
This is your sample where a , is missing before "data"
{"_id": "e940717f486026242e9b5d9cd80023d2","_rev": "1-967a00dff5e02add41819138abb3284d" "data": "Hello World"}
It should be like this one
{"_id": "e940717f486026242e9b5d9cd80023d2",
"_rev": "1-967a00dff5e02add41819138abb3284d",
"data": "Hello World"
}
JSON syntax should be correct, otherwise it will not be saved

Missing params from body when sandbox environment

We are implementing push server notifications and during our tests we are getting way too few parameters in json from apple which makes it impossible to identify the subscription.
Table 6.3 in their documentation claims that body contains several params amongst original_transaction_id, latest_receipt, latest_receipt_info etc.
Though, we are only getting for INTERACTIVE_RENEWAL type:
{
"auto_renew_product_id": "agreement_chat_MO_auto_renewal",
"password": "CORRECT_PASSWORD_HERE",
"environment": "Sandbox",
"auto_renew_status": "false",
"notification_type": "INTERACTIVE_RENEWAL"
}
and for DID_CHANGE_RENEWAL_STATUS type:
{
"auto_renew_status_change_date": "2019-06-03 08:13:11 Etc/GMT",
"environment": "Sandbox",
"auto_renew_status": "false",
"auto_renew_status_change_date_pst": "2019-06-03 01:13:11 America/Los_Angeles",
"password": "CORRECT_PASSWORD_HERE",
"auto_renew_status_change_date_ms": "1559549591000",
"auto_renew_product_id": "the_product_id",
"notification_type": "DID_CHANGE_RENEWAL_STATUS"
}
Given those params, it is impossible to find the subscription the notification refers at.
Am I missing something here? Is the sandbox broken in any way?
You are not the only one...
https://forums.developer.apple.com/thread/116996
It has been broken in Sandbox for days now. We checked our logs and they had this error in production for some time. Now in production it seems to be fixed, but the problem persists in Sandbox.

JMeter - If Controller not working for certain string contains condition?

Background:
I have an API that returns a response like so:
{
"status": 1,
"errorCode": null,
"message": null,
"data": [
{
"id": 33,
"snapshotId": 2,
"ceId": 29,
"month": "Feb",
"corpRcvPayAmt": 100000,
"wthRcvPayAmt": -90000
},
{
"id": 31,
"snapshotId": 2,
"ceId": 29,
"month": "Jan",
"corpRcvPayAmt": 0,
"wthRcvPayAmt": 0
}
]
}
The data node can vary from 0 size to 12 (empty to 1 per month). The only constant field for data is the "month" node. Other field values are changing.
Goal:
I want to do either a PUT or a POST request, depending on whether or not a specific month is already present in data.
For this, I'm capturing the entire data field into a variable using a Regular Expression Extractor like this:
With the sample response above, calling ${data} will give me {"id":33,"snapshotId":2,"ceId":29,"month":"Feb","corpRcvPayAmt":100000.00,"wthRcvPayAmt":-90000.00},{"id":31,"snapshotId":2,"ceId":29,"month":"Jan","corpRcvPayAmt":0.00,"wthRcvPayAmt":0.00}
Now using this field, I just want to do a simple if condition like so: if ${data} contains ${month} do something (PUT request). I'm currently trying to do it like this:
Problem:
The condition ${__groovy("${data}".contains("Jan"))} does not seem to work.
I've already tried doing the following:
change the condition to ${__groovy("${month}".contains("Jan"))} just to see if the syntax is correct. This works just fine.
Add a debug sampler inside the if controller using the condition ${__groovy("${month}".contains("Jan"))} to print ${data}. This also prints the data as expected.
I also tried using various js syntax for the if condition but so far groovy is the ongiving the best results.
With this I can confirm the following:
${month} and ${data} are extracted and stored properly
groovy syntax for string contains is working properly
for some reason, the condition ${__groovy("${data}".contains("Jan"))} is not working.
What am I missing here? Thanks in advance.
Don't reference JMeter Functions and/or Variables in Groovy scripts as:
There could be a conflict with GString Template
For JSR223 Test Elements it causes compilation cache feature malfunction reducing the performance
Your variable might simply resolve into something which will cause Groovy script compilation failure and/or malfunction. You can check jmeter.log file for the actual error details.
So instead of using ${data} go for vars.get("data") instead, vars is a shorthand for JMeterVariables class instance and this is the best way of getting a JMeter Variable value from the Groovy script.
The whole function should look like:
${__groovy(vars.get('data').contains("Jan"),)}
Also be aware that it's better to use JSON Extractor for obtaining values from JSON responses.

Zapier CLI Trigger - How to use defined sample data when no results returned during setup

I am trying to prototype a trigger using the Zapier CLI and I am running to an issue with the 'Pull In Samples' section when setting up the trigger in the UI.
This tries to pull in a live sample of data to use, however the documentation states that if no results are returned it will use the sample data that is configured for the trigger.
In most cases there will be no live data and so ideally would actually prefer the sample data to be used in the first instance, however my trigger does not seem to ever use the sample and I have not been able to find a concrete example of a 'no results' response.
The API I am using returns XML so I am manipulating the result into JSON which works fine if there is data.
If there are no results so far I have tried returning '[]', but that just hangs and if I check the zapier http logs it's looping http requests until I cancel the sample check.
Returning '[{}]' returns an error that I need an 'id' field.
The definition I am using is:
module.exports = {
key: 'getsmsinbound',
noun: 'GetSMSInbound',
display: {
label: 'Get Inbound SMS',
description: 'Check for inbound SMS'
},
operation: {
inputFields: [
{ key: 'number', required: true, type: 'string', helpText: 'Enter the inbound number' },
{ key: 'keyword', required: false, type: 'string', helpText: 'Optional if you have configured a keyword and you wish to check for specific keyword messages.' },
],
perform: getsmsinbound,
sample: {
id: 1,
originator: '+447980123456',
destination: '+447781484146',
keyword: '',
date: '2009-07-08',
time: '10:38:55',
body: 'hello world',
network: 'Orange'
}
}
};
I'm hoping it's something obvious as on scouring the web and Zapier documentation I've not had any luck!
Sample data must be provided from your app and the sample payload is not used for this poll specifically. From the docs:
Sample results will NOT be used for a user's Zap testing step. That
step requires data to be received by an event or returned from a
polling URL. If a user chooses to "Skip Test", then the sample result,
if provided, will be used.
Personally, I have never seen "Skip Test" show up. A while back I asked support about this:
That's a great question! It's definitely one of those "chicken and
egg" situations when using REST Hooks - if there isn't a sample
available, then everything just stalls.
When the Zap editor tries to obtain a "sample result", there are three
places where it's going to look:
The Polling endpoint (in Step #3 of your trigger's setup) is invoked for the current user. If that returns "nothing", then the Zap
editor will try the next step.
The "most recent record/data" in the Zap's history. Since this is a brand new Zap, there won't be anything present.
The Sample result (in Step #4 of your trigger's setup). The Zap editor will tell the user that there's "nothing to show", and will
give the user the option to "skip test and continue", which will use
the sample JSON that you've provided here.
In reality, it will just continue to retry the request over and over and never provide the user with a "skip test and continue" option. I just emailed again asking if anything has changed since then, but it looks like existing sample data is a requirement.
Perhaps create a record in your API by default and hide it from normal use and just send back that one?
Or send back dummy data even though Zapier says not to. Not sure, but I don't know how people can set up a zap when no data has been created yet (and Zapier says not many of their apps have this issue, but nearly every trigger I've created and ever use case for other applications would hint to me otherwise).

How do I retrieve step count data from Google Fitness REST api?

Since I installed the Google Fit app on my Nexus 5 it has been tracking my step count and time spent walking. I'd like to retrieve this info via the Google Fitness REST api (docs) but I can't work out how to get any of that data from the REST api.
I've used the OAuth 2.0 playground to successfully list dataSources but none of the examples I have tried have returned any fitness data whatsoever. I feel like I need to use something similar to a DataReadRequest from the (Android SDK) but I'm not building an Android app -- I just want to access fitness data already stored by the Google Fit app.
Is it even possible to get the data gathered by the Google Fit app? If so, how can I read and aggregate step count data using the REST api?
It turns out that the answer is in the docs after all. Here is the format of the request.
GET https://www.googleapis.com/fitness/v1/users/{userId}/dataSources/{dataSourceId}/datasets/{datasetId}
The only supported {userId} value is me (with authentication).
Possible values for {dataSourceId} are avaiable by running a different request.
The bit I missed was that {datasetId} is not really an ID, but actually where you define the timespan in which you are interested. The format for that variable is {startTime}-{endTime} where the times are in nanoseconds since the epoch.
I was able to get this working by going through the google php client and noticed that they append their start and finish times for the GET request with extra 0's - nine infact.
Use the same GET request format as mentioned in an answer above:
https://www.googleapis.com/fitness/v1/users/{userId}/dataSources/{dataSourceId}/datasets/{datasetId}
Now here is an example with the unix timestamp (php's time() function uses this)
https://www.googleapis.com/fitness/v1/users/me/dataSources/derived:com.google.step_count.delta:com.google.android.gms:estimated_steps/datasets/1470475368-1471080168
This is the response I get:
{
"minStartTimeNs": "1470475368",
"maxEndTimeNs": "1471080168",
"dataSourceId":
"derived:com.google.step_count.delta:com.google.android.gms:estimated_steps
}
However if you append your start and finish times with nine 0's that you put in your GET requests and shape your request like this:
https://www.googleapis.com/fitness/v1/users/me/dataSources/derived:com.google.step_count.delta:com.google.android.gms:estimated_steps/datasets/1470475368000000000-1471080168000000000
It worked - this is the response I got:
{
"minStartTimeNs": "1470475368000000000",
"maxEndTimeNs": "1471080168000000000",
"dataSourceId":
"derived:com.google.step_count.delta:com.google.android.gms:estimated_steps",
"point": [
{
"modifiedTimeMillis": "1470804762704",
"startTimeNanos": "1470801347560000000",
"endTimeNanos": "1470801347567000000",
"value": [
{
"intVal": -3
}
],
"dataTypeName": "com.google.step_count.delta",
"originDataSourceId": "raw:com.google.step_count.delta:com.dsi.ant.plugins.antplus:AntPlus.0.124"
},
The response is a lot longer but I truncated it for the sake of this post. So when passing your datasets parameter into the request:
1470475368-1471080168 will not work, but 1470475368000000000-1471080168000000000 will.
This did the trick for me, hopes it helps someone!
I tried post method with below URL & body. This will work, please check inline comments too.
Use URL: https://www.googleapis.com/fitness/v1/users/me/dataset:aggregate
Method: POST
Body:
{
"aggregateBy": [{
"dataTypeName": "com.google.step_count.delta",
"dataSourceId": "derived:com.google.step_count.delta:com.google.android.gms:estimated_steps"
}],
"bucketByTime": { "durationMillis": 86400000 }, // This is 24 hours
"startTimeMillis": 1504137600000, //start time
"endTimeMillis": 1504310400000 // End Time
}

Resources