Yodlee: empty list of transactions on a test account - yodlee

I've registered test account with Yodlee and tried code sample for NodeJS.
The idea was to get a list of transactions of a test user. Nothing. Never seen and example of how to specify, say, fromDate and toDate parameters, as recommended.
Could you please drop a very simple code listing transactions of a user?
Thanks in advance.

From Yodlee API docs:
By default, this service returns the last 30 days of transactions from today's date.
You are receiving an empty transactions list with valid API call since all their demo transactions in dev sandboxes are being created with "2013-mm-dd" timestamp - so that's why the same API call by #Krithik returns some data.

Here is the sample code for getting transactions. Hope this helps
var http = require("https");
var options = {
"method": "GET",
"hostname": "developer.api.yodlee.com",
"port": null,
"path": "/ysl/restserver/v1/transactions?container=bank&fromDate=2013-01-05&toDate=2016-12-20",
"headers": {
"authorization": "cobSession=08062013_2:99be18ed5a16856c1e1f3cce1cadd064152c6c3664d5aac935a72992967f20dbf057bdb8580ada5c29dd29fff6fd9baa20238c4384ab0be9d8e80a708b301bb0,userSession=08062013_0:1f5692792f5b97a1c825fb8fbe687023f583c9b5029d8437c90ddb99c9eb77539cef1b37005e5007cbdeb2df272626b49ce1c3cc9539ef52526c267a1de238b7",
"cache-control": "no-cache"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();

Related

Website login automation without XHR request

Background: I'm trying to automate local ISP login using simple request in python (without selenium, that's last resort as I'm trying to learn other ways too).
Upon inspecting website, submit button calls the validateForm() function.
function validateForm(){
var input=true;
var uname = "?"+document.login.Username.value+"+/#";
var pwd = "?"+document.login.Password.value+"+/#";
document.login.LoginName.value=encodeURIComponent(uname);
document.login.LoginPassword.value=encodeURIComponent(pwd);
if (input==true&&document.login.checker.checked)
toMem(this);
}
function toMem(a) {
newCookie('theName', document.login.Username.value); // add a new cookie as shown at left for every
newCookie('theEmail', document.login.Password.value); // field you wish to have the script remember
}
function newCookie(Username,value,days) {
var days = 30; // the number at the left reflects the number of days for the cookie to last
// modify it according to your needs
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString(); }
else var expires = "";
document.cookie = Username+"="+value+expires+"; path=/";
}
No where it is sending any request.
The website doesn't make any XHR request. I'm not able to grasp how they are making the login work. I found one request from 'other' tab of network (chrome dev tools). From where it is generating this request!!!
fetch("http://ip:port/Sristi3/SRISTI/loginUI.do2", {
"headers": {
"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
"accept-language": "en-US,en;q=0.9,bn;q=0.8",
"cache-control": "no-cache",
"content-type": "application/x-www-form-urlencoded",
"pragma": "no-cache",
"upgrade-insecure-requests": "1"
},
"referrer": "http://ip:port/Sristi3/SRISTI/Login.jsp?",
"referrerPolicy": "no-referrer-when-downgrade",
"body": "Username=username&Password=password&LoginName=encodedusername&LoginPassword=encodedpass",
"method": "POST",
"mode": "cors",
"credentials": "include"
});
I tried to simply paste the request in console but this also does not make the login. Returned a promise with [[PromiseStatus]]: "rejected" and [[PromiseValue]]: TypeError: Failed to fetch, message: "Failed to fetch", stack: "TypeError: Failed to fetch". What and where to look for? Any help?

Stripe API error - "Received unknown parameter: source"

Creating subscription site in wix code. I keep getting a 400 unknown parameter: source error. (/subscripton)
if you can spot where i am going wrong it would be appreciated. thanks!
import { fetch } from 'wix-fetch';
export async function subscription(token, item) {
const cart = item;
const apiKey = "PRIVATEAPI";
const response = await
fetch("https://api.stripe.com/v1/subscriptions", {
method: 'post',
headers: {
"Content-Type": "application/x-www-form-urlencoded",
"Authorization": "Bearer " + apiKey
},
body: encodeBody(token, cart)
});
if (response.status >= 200 && response.status < 300) {
const ret = await response.json();
return { "chargeId": ret.id };
}
let res = await response.json();
let err = res.error.message;
let code = res.error.code;
let type = res.error.type;
return { "error": err, "code": code, "type": type };
}
function encodeBody(token, cart) {
let encoded = "";
for (let [k, v] of Object.entries(cart)) {
encoded = encoded.concat(k, "=", encodeURI(v), "&");
}
encoded = encoded.concat("source=", encodeURI(token));
return encoded;
}
welcome to StackOverflow!
It looks like you're creating a Subscription. According to the API docs: https://stripe.com/docs/api/subscriptions/create?lang=ruby
customer is a required parameter when creating subscriptions on Stripe. You would need to create a Customer first, attaching a tokenized card to the Customer as a source. Then, you can create a subscription, by passing customer: customer.id
Also, is this request being made client-side? Requests made with your secret API key should be made from your server-side code and preferably using Stripe's API libraries: https://stripe.com/docs/libraries
Since you're using Subscriptions, you should also look into the new version of Stripe Checkout (https://stripe.com/docs/payments/checkout), it allows creating subscriptions with client-side code with just a few lines of code!
You're likely passing additional keys that you're not expecting to when you call encodeBody(token, cart).
You should verify that the keys you're passing in token and cart are all valid according to the documentation at https://stripe.com/docs/api/subscriptions/create.

405 error with JIRA REST API using node js

I am trying to create an automated JIRA ticket using the REST API but I keep getting a 405 error.
I am using the examples here: https://developer.atlassian.com/server/jira/platform/jira-rest-api-examples/
Also, when I visit the post URL directly I do not get any errors so I doubt it is a server issue. Any ideas?
var Client = require('node-rest-client').Client;
client = new Client();
// Provide user credentials, which will be used to log in to Jira.
var loginArgs = {
data: {
"username": "user",
"password": "pass"
},
headers: {
"Content-Type": "application/json"
}
};
client.post("https://jira.mydomain.com/rest/auth/1/session", loginArgs, function(data, response) {
if (response.statusCode == 200) {
//console.log('succesfully logged in, session:', data.session);
var session = data.session;
// Get the session information and store it in a cookie in the header
var args = {
headers: {
// Set the cookie from the session information
cookie: session.name + '=' + session.value,
"Content-Type": "application/json"
},
data: {
// I copied this from the tutorial
"fields": {
"project": {
"key": "REQ"
},
"summary": "REST ye merry gentlemen.",
"description": "Creating of an issue using project keys and issue type names using the REST API",
"issuetype": {
"name": "Request"
}
}
}
};
// Make the request return the search results, passing the header information including the cookie.
client.post("https://jira.mydomain.com/rest/api/2/issue/createmeta", args, function(searchResult, response) {
console.log('status code:', response.statusCode);
console.log('search result:', searchResult);
});
} else {
throw "Login failed :(";
}
});
I am expecting the Jira ticket of type REQ to be created with the details I added in the fields section.
I believe you are using the incorrect REST API; what you're currently doing is doing a POST to Get create issue meta which requires a GET method, hence, you're getting a 405. If you want to create an issue, kindly use Create issue (POST /rest/api/2/issue) instead.

Cancel all Google/Firebase messaging subscriptions

I just rewrote my firebase cloud messaging code for my web API and now use a Cloud Function to handle the subscriptions, or at least that is the theory.
Where can I go to cancel any existing subscriptions so that I can check that what seems now to be working, actually is (and that is not some hangover from before that is giving the impression of working).
This is all on a development instance of Firebase so I can delete whatever I want. I set up the subscriptions with the following code, which may or may not be coreect, but I think it means I need to look on Google rather than Firebase, but I can't find anything
let token = req.query.token;
let topic = "presents";
let uri = `https://iid.googleapis.com/iid/v1/${token}/rel/topics/${topic}`;
// Make the request to Google IID
var myHeaders = {
"Content-Type": "application/json",
Authorization: "key=" + secrets.devKey
};
var options = {
uri: uri,
method: "POST",
headers: myHeaders,
mode: "no-cors",
cache: "default"
};
rp(options)
.then(function(response) {
// console.log("rp success", response);
res.status(200).send({
msg: "Ok from Simon for " + token,
payload: response}
);
})
.catch(function(err) {
console.log("[fbm.registerForUpdates] Error registering for topic", err.message);
res.status(500).send(err);
});
The Firebase documentation seems to be incomplete on this topic. Playing around showed the following (valid at least at the time of writing, verified w/ Postman):
POST https://iid.googleapis.com/iid/v1/IID_TOKEN/rel/topics/TOPIC_NAME request creates a subscription for a topic & token
GET https://iid.googleapis.com/iid/info/IID_TOKEN?details=true request lists all subscribed topics for a token
DELETE https://iid.googleapis.com/iid/v1/IID_TOKEN/rel/topics/TOPIC_NAME request removes a subscription for a topic for a token
DELETE https://iid.googleapis.com/v1/web/iid/IID_TOKEN request removes all subscriptions for a token
On all these requests the header 'Authorization: key=YOUR_SERVER_KEY' needs to be set.
Sample output from a GET request:
{
"connectDate": "2018-10-06",
"application": "com.chrome.macosx",
"subtype": "wp:https://192.168.0.196:8020/#9885158F-953C-48BC-BCF5-38ABF2F89-V2",
"scope": "*",
"authorizedEntity": "30916174593",
"rel": {
"topics": {
"sensorUpdate": {
"addDate": "2018-10-07"
}
}
},
"connectionType": "WIFI",
"platform": "BROWSER"
}

Getting no records when making Ajax request

I am trying to make a request to a server but im getting no records. When i run the code I am getting no error messages so I assume my code is working but when the callback function is executed on store load I just get a blank message.
var proxy = Ext.data.proxy.Ajax.create({
type:'ajax',
url:loginHostUri,
method:'POST',
headers:{
'Accept':'application/x-www-form-urlencoded'
},
extraParams:{
grant_type:'password',
username:username,
password:psswd,
client_id: consumerKey,
client_secret: consumerSecret
},
reader:{
type:'json',
root:''
}
});
var store = Ext.getStore('instance');
store.setProxy(proxy);
store.load({
callback:function(records,operation,success){
Ext.Msg.alert('INFO',records,Ext.emptyFn);
},
scope:this
});
The message is just blank but I know the Json response looks like this:
{
"":{
"id":"2332123",
"issued_at":"090342",
" instance_url":"instance",
"signature":"sig",
"access_token":"access"
}
}
define a fields or a model for the store
store.setFields({name: 'id', name: 'issued_id' ...});(put this before store.load())
Try that and console.log(records) under callback and reply back what you get...